Merge
authorduke
Wed, 05 Jul 2017 18:57:02 +0200
changeset 17653 23eb0edfd0d9
parent 17652 fe7926936461 (current diff)
parent 17648 c86a0c21415e (diff)
child 17654 2fd6acba737b
Merge
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/amd64/AMD64CFrame.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/x86/X86CFrame.java
hotspot/test/runtime/7158804/Test7158804.sh
hotspot/test/runtime/8003985/Test8003985.java
--- a/.hgtags-top-repo	Wed May 29 10:16:32 2013 -0700
+++ b/.hgtags-top-repo	Wed Jul 05 18:57:02 2017 +0200
@@ -212,3 +212,4 @@
 e1a929afcfc492470d50be0b6b0e8dc77d3760b9 jdk8-b88
 892a0196d10c67f3a12f0eefb0bb536e423d8868 jdk8-b89
 69b773a221b956a3386933ecdbfeccee0edeac47 jdk8-b90
+cb51fb4789ac0b8be4056482077ddfb8f3bd3805 jdk8-b91
--- a/common/autoconf/basics.m4	Wed May 29 10:16:32 2013 -0700
+++ b/common/autoconf/basics.m4	Wed Jul 05 18:57:02 2017 +0200
@@ -23,14 +23,23 @@
 # questions.
 #
 
+# Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
+# If so, then append $1 to $2\
+# Also set JVM_ARG_OK to true/false depending on outcome.
 AC_DEFUN([ADD_JVM_ARG_IF_OK],
 [
-    # Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
-    # If so, then append $1 to $2
-    FOUND_WARN=`$3 $1 -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$3 $1 -version 2>&1 | grep " version \""`
+    $ECHO "Check if jvm arg is ok: $1" >&AS_MESSAGE_LOG_FD
+    $ECHO "Command: $3 $1 -version" >&AS_MESSAGE_LOG_FD
+    OUTPUT=`$3 $1 -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         $2="[$]$2 $1"
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&AS_MESSAGE_LOG_FD
+	$ECHO "$OUTPUT" >&AS_MESSAGE_LOG_FD
+	JVM_ARG_OK=false
     fi
 ])
 
@@ -51,16 +60,19 @@
   else
     # We're on a posix platform. Hooray! :)
     path="[$]$1"
-    
-    if test ! -f "$path" && test ! -d "$path"; then
-      AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.])
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.])
       AC_MSG_ERROR([Spaces are not allowed in this path.])
     fi
+
+    # Use eval to expand a potential ~
+    eval path="$path"
+    if test ! -f "$path" && test ! -d "$path"; then
+      AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.])
+    fi
+
+    $1="`cd "$path"; $THEPWDCMD`" 
   fi
 ])
 
--- a/common/autoconf/build-performance.m4	Wed May 29 10:16:32 2013 -0700
+++ b/common/autoconf/build-performance.m4	Wed Jul 05 18:57:02 2017 +0200
@@ -278,60 +278,37 @@
 fi                    
 AC_SUBST(SJAVAC_SERVER_JAVA)
 
-AC_ARG_WITH(sjavac-server-cores, [AS_HELP_STRING([--with-sjavac-server-cores],
-	[use at most this number of concurrent threads on the sjavac server @<:@probed@:>@])])
-if test "x$with_sjavac_server_cores" != x; then
-    SJAVAC_SERVER_CORES="$with_sjavac_server_cores"
-else
-    if test "$NUM_CORES" -gt 16; then
-        # We set this arbitrary limit because we want to limit the heap
-        # size of the javac server.
-        # In the future we will make the javac compilers in the server
-        # share more and more state, thus enabling us to use more and
-        # more concurrent threads in the server.
-        SJAVAC_SERVER_CORES="16"
-    else
-        SJAVAC_SERVER_CORES="$NUM_CORES"
+if test "$MEMORY_SIZE" -gt "2500"; then
+    ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+    if test "$JVM_ARG_OK" = true; then
+        JVM_64BIT=true
+	JVM_ARG_OK=false
+    fi
     fi
 
+if test "$JVM_64BIT" = true; then
     if test "$MEMORY_SIZE" -gt "17000"; then
-        MAX_HEAP_MEM=10000
-        ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
         ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
-    elif test "$MEMORY_SIZE" -gt "10000"; then
-        MAX_HEAP_MEM=6000
-        ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+    fi
+    if test "$MEMORY_SIZE" -gt "10000" && test "$JVM_ARG_OK" = false; then
         ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
-    elif test "$MEMORY_SIZE" -gt "5000"; then
-        MAX_HEAP_MEM=3000
-        ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+    fi
+    if test "$MEMORY_SIZE" -gt "5000" && test "$JVM_ARG_OK" = false; then
         ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
-    elif test "$MEMORY_SIZE" -gt "3800"; then
-        MAX_HEAP_MEM=2500
+    fi
+    if test "$MEMORY_SIZE" -gt "3800" && test "$JVM_ARG_OK" = false; then
         ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
-    elif test "$MEMORY_SIZE" -gt "1900"; then
-        MAX_HEAP_MEM=1200
-        ADD_JVM_ARG_IF_OK([-Xms700M -Xmx1400M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
-    elif test "$MEMORY_SIZE" -gt "1000"; then
-        MAX_HEAP_MEM=900
-        ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
-    else
-        MAX_HEAP_MEM=512
-        ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
     fi
-
-    ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
-    ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
-    ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
-
-    MAX_COMPILERS_IN_HEAP=`expr $MAX_HEAP_MEM / 501`
-    if test "$SJAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then
-        AC_MSG_CHECKING([if number of server cores must be reduced])
-        SJAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP"
-        AC_MSG_RESULT([yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB])
-    fi
-fi                    
-AC_SUBST(SJAVAC_SERVER_CORES)
+fi
+if test "$MEMORY_SIZE" -gt "2500" && test "$JVM_ARG_OK" = false; then
+    ADD_JVM_ARG_IF_OK([-Xms1000M -Xmx1500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+fi
+if test "$MEMORY_SIZE" -gt "1000" && test "$JVM_ARG_OK" = false; then
+    ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+fi
+if test "$JVM_ARG_OK" = false; then
+    ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+fi
 
 AC_MSG_CHECKING([whether to use sjavac])
 AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac],
--- a/common/autoconf/generated-configure.sh	Wed May 29 10:16:32 2013 -0700
+++ b/common/autoconf/generated-configure.sh	Wed Jul 05 18:57:02 2017 +0200
@@ -599,7 +599,6 @@
 USE_PRECOMPILED_HEADER
 SJAVAC_SERVER_DIR
 ENABLE_SJAVAC
-SJAVAC_SERVER_CORES
 SJAVAC_SERVER_JAVA
 JOBS
 MEMORY_SIZE
@@ -682,6 +681,8 @@
 SHARED_LIBRARY
 OBJ_SUFFIX
 COMPILER_NAME
+JTREGEXE
+JT_HOME
 LIPO
 ac_ct_OBJDUMP
 OBJDUMP
@@ -1005,6 +1006,7 @@
 with_dxsdk
 with_dxsdk_lib
 with_dxsdk_include
+with_jtreg
 with_extra_cflags
 with_extra_cxxflags
 with_extra_ldflags
@@ -1025,7 +1027,6 @@
 with_memory_size
 with_jobs
 with_sjavac_server_java
-with_sjavac_server_cores
 enable_sjavac
 enable_precompiled_headers
 enable_ccache
@@ -1764,6 +1765,7 @@
                           [probed]
   --with-dxsdk-include    the DirectX SDK include directory (Windows only)
                           [probed]
+  --with-jtreg            Regression Test Harness [probed]
   --with-extra-cflags     extra flags to be used when compiling jdk c-files
   --with-extra-cxxflags   extra flags to be used when compiling jdk c++-files
   --with-extra-ldflags    extra flags to be used when linking jdk
@@ -1796,9 +1798,6 @@
   --with-sjavac-server-java
                           use this java binary for running the sjavac
                           background server [Boot JDK java]
-  --with-sjavac-server-cores
-                          use at most this number of concurrent threads on the
-                          sjavac server [probed]
   --with-ccache-dir       where to store ccache files [~/.ccache]
 
 Some influential environment variables:
@@ -3077,6 +3076,9 @@
 # questions.
 #
 
+# Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
+# If so, then append $1 to $2\
+# Also set JVM_ARG_OK to true/false depending on outcome.
 
 
 # This will make sure the given variable points to a full and proper
@@ -3725,6 +3727,9 @@
 
 
 
+# Setup the JTREG paths
+
+
 #
 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -3775,7 +3780,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1367502949
+DATE_WHEN_GENERATED=1369723814
 
 ###############################################################################
 #
@@ -7389,17 +7394,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$SRC_ROOT"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of SRC_ROOT, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of SRC_ROOT, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of SRC_ROOT, 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 SRC_ROOT, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    SRC_ROOT="`cd "$path"; $THEPWDCMD`"
   fi
 
 
@@ -7508,17 +7516,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$CURDIR"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of CURDIR, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of CURDIR, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of CURDIR, 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 CURDIR, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    CURDIR="`cd "$path"; $THEPWDCMD`"
   fi
 
 
@@ -8104,17 +8115,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$OUTPUT_ROOT"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of OUTPUT_ROOT, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OUTPUT_ROOT, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of OUTPUT_ROOT, 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 OUTPUT_ROOT, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    OUTPUT_ROOT="`cd "$path"; $THEPWDCMD`"
   fi
 
 
@@ -11161,17 +11175,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -11490,17 +11507,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -11633,17 +11653,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$JAVA_HOME_PROCESSED"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JAVA_HOME_PROCESSED, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of JAVA_HOME_PROCESSED, 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 JAVA_HOME_PROCESSED, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    JAVA_HOME_PROCESSED="`cd "$path"; $THEPWDCMD`"
   fi
 
         if test ! -d "$JAVA_HOME_PROCESSED"; then
@@ -11802,17 +11825,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -11987,17 +12013,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -12312,17 +12341,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -12524,17 +12556,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -12701,17 +12736,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -12906,17 +12944,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -13083,17 +13124,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -13288,17 +13332,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -13465,17 +13512,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -13670,17 +13720,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -13847,17 +13900,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -14039,17 +14095,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -14214,17 +14273,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -14407,17 +14469,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -14582,17 +14647,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -14774,17 +14842,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -14949,17 +15020,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -15142,17 +15216,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -15317,17 +15394,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -15491,17 +15571,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$BOOT_JDK"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of BOOT_JDK, 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 BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    BOOT_JDK="`cd "$path"; $THEPWDCMD`"
   fi
 
               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5
@@ -15705,73 +15788,115 @@
 
     # Minimum amount of heap memory.
 
-    # Test if -Xms64M is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -Xms64M to boot_jdk_jvmargs
-    FOUND_WARN=`$JAVA -Xms64M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$JAVA -Xms64M -version 2>&1 | grep " version \""`
+    $ECHO "Check if jvm arg is ok: -Xms64M" >&5
+    $ECHO "Command: $JAVA -Xms64M -version" >&5
+    OUTPUT=`$JAVA -Xms64M -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         boot_jdk_jvmargs="$boot_jdk_jvmargs -Xms64M"
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
     fi
 
     if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
         # Why does macosx need more heap? Its the huge JDK batch.
 
-    # Test if -Xmx1600M is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -Xmx1600M to boot_jdk_jvmargs
-    FOUND_WARN=`$JAVA -Xmx1600M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$JAVA -Xmx1600M -version 2>&1 | grep " version \""`
+    $ECHO "Check if jvm arg is ok: -Xmx1600M" >&5
+    $ECHO "Command: $JAVA -Xmx1600M -version" >&5
+    OUTPUT=`$JAVA -Xmx1600M -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         boot_jdk_jvmargs="$boot_jdk_jvmargs -Xmx1600M"
-    fi
-
-    else
-
-    # Test if -Xmx1100M is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -Xmx1100M to boot_jdk_jvmargs
-    FOUND_WARN=`$JAVA -Xmx1100M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$JAVA -Xmx1100M -version 2>&1 | grep " version \""`
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
+    fi
+
+    else
+
+    $ECHO "Check if jvm arg is ok: -Xmx1100M" >&5
+    $ECHO "Command: $JAVA -Xmx1100M -version" >&5
+    OUTPUT=`$JAVA -Xmx1100M -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         boot_jdk_jvmargs="$boot_jdk_jvmargs -Xmx1100M"
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
     fi
 
     fi
     # When is adding -client something that speeds up the JVM?
     # ADD_JVM_ARG_IF_OK([-client],boot_jdk_jvmargs,[$JAVA])
 
-    # Test if -XX:PermSize=32m is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -XX:PermSize=32m to boot_jdk_jvmargs
-    FOUND_WARN=`$JAVA -XX:PermSize=32m -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$JAVA -XX:PermSize=32m -version 2>&1 | grep " version \""`
+    $ECHO "Check if jvm arg is ok: -XX:PermSize=32m" >&5
+    $ECHO "Command: $JAVA -XX:PermSize=32m -version" >&5
+    OUTPUT=`$JAVA -XX:PermSize=32m -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         boot_jdk_jvmargs="$boot_jdk_jvmargs -XX:PermSize=32m"
-    fi
-
-
-    # Test if -XX:MaxPermSize=160m is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -XX:MaxPermSize=160m to boot_jdk_jvmargs
-    FOUND_WARN=`$JAVA -XX:MaxPermSize=160m -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$JAVA -XX:MaxPermSize=160m -version 2>&1 | grep " version \""`
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
+    fi
+
+
+    $ECHO "Check if jvm arg is ok: -XX:MaxPermSize=160m" >&5
+    $ECHO "Command: $JAVA -XX:MaxPermSize=160m -version" >&5
+    OUTPUT=`$JAVA -XX:MaxPermSize=160m -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         boot_jdk_jvmargs="$boot_jdk_jvmargs -XX:MaxPermSize=160m"
-    fi
-
-
-    # Test if -XX:ThreadStackSize=$STACK_SIZE is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -XX:ThreadStackSize=$STACK_SIZE to boot_jdk_jvmargs
-    FOUND_WARN=`$JAVA -XX:ThreadStackSize=$STACK_SIZE -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$JAVA -XX:ThreadStackSize=$STACK_SIZE -version 2>&1 | grep " version \""`
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
+    fi
+
+
+    $ECHO "Check if jvm arg is ok: -XX:ThreadStackSize=$STACK_SIZE" >&5
+    $ECHO "Command: $JAVA -XX:ThreadStackSize=$STACK_SIZE -version" >&5
+    OUTPUT=`$JAVA -XX:ThreadStackSize=$STACK_SIZE -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         boot_jdk_jvmargs="$boot_jdk_jvmargs -XX:ThreadStackSize=$STACK_SIZE"
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
     fi
 
     # Disable special log output when a debug build is used as Boot JDK...
 
-    # Test if -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput to boot_jdk_jvmargs
-    FOUND_WARN=`$JAVA -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$JAVA -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput -version 2>&1 | grep " version \""`
+    $ECHO "Check if jvm arg is ok: -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput" >&5
+    $ECHO "Command: $JAVA -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput -version" >&5
+    OUTPUT=`$JAVA -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         boot_jdk_jvmargs="$boot_jdk_jvmargs -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput"
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
     fi
 
 fi
@@ -16132,6 +16257,157 @@
 
 # Locate the actual tools
 
+
+# Check whether --with-jtreg was given.
+if test "${with_jtreg+set}" = set; then :
+  withval=$with_jtreg;
+fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JTReg Regression Test Harness" >&5
+$as_echo_n "checking for JTReg Regression Test Harness... " >&6; }
+
+  if test "x$with_jtreg" != x; then
+    JT_HOME="$with_jtreg"
+
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+  # Input might be given as Windows format, start by converting to
+  # unix format.
+  path="$JT_HOME"
+  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 JT_HOME, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of JT_HOME, which resolves as \"$path\", is invalid." >&6;}
+    as_fn_error $? "Cannot locate the the path of JT_HOME" "$LINENO" 5
+  fi
+
+  # Call helper function which possibly converts this using DOS-style short mode.
+  # If so, the updated path is stored in $new_path.
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+      # Going to short mode and back again did indeed matter. Since short mode is
+      # case insensitive, let's make it lowercase to improve readability.
+      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+      # Now convert it back to Unix-stile (cygpath)
+      input_path=`$CYGPATH -u "$shortmode_path"`
+      new_path="$input_path"
+    fi
+  fi
+
+  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+  if test "x$test_cygdrive_prefix" = x; then
+    # As a simple fix, exclude /usr/bin since it's not a real path.
+    if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+      # a path prefixed by /cygdrive for fixpath to work.
+      new_path="$CYGWIN_ROOT_PATH$input_path"
+    fi
+  fi
+
+
+  if test "x$path" != "x$new_path"; then
+    JT_HOME="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting JT_HOME to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting JT_HOME to \"$new_path\"" >&6;}
+  fi
+
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+  path="$JT_HOME"
+  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
+    JT_HOME="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting JT_HOME to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting JT_HOME 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 posix platform. Hooray! :)
+    path="$JT_HOME"
+    has_space=`$ECHO "$path" | $GREP " "`
+    if test "x$has_space" != x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JT_HOME, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of JT_HOME, 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 JT_HOME, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    JT_HOME="`cd "$path"; $THEPWDCMD`"
+  fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JT_HOME" >&5
+$as_echo "$JT_HOME" >&6; }
+
+    # jtreg win32 script works for everybody
+    JTREGEXE="$JT_HOME/win32/bin/jtreg"
+    if test ! -f "$JTREGEXE"; then
+      as_fn_error $? "JTReg executable does not exist: $JTREGEXE" "$LINENO" 5
+    fi
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  fi
+
+
+
+
+
 if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 
   # Store path to cygwin link.exe to help excluding it when searching for
@@ -17088,17 +17364,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$MSVCR_DLL"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of MSVCR_DLL, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MSVCR_DLL, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of MSVCR_DLL, which resolves as \"$path\", is invalid." >&6;}
       as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
     fi
+
+    # Use eval to expand a potential ~
+    eval path="$path"
+    if test ! -f "$path" && test ! -d "$path"; then
+      as_fn_error $? "The path of MSVCR_DLL, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    MSVCR_DLL="`cd "$path"; $THEPWDCMD`"
   fi
 
 
@@ -17242,17 +17521,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$dxsdk_path"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of dxsdk_path, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of dxsdk_path, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of dxsdk_path, 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 dxsdk_path, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    dxsdk_path="`cd "$path"; $THEPWDCMD`"
   fi
 
 
@@ -17377,17 +17659,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$DXSDK_LIB_PATH"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of DXSDK_LIB_PATH, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of DXSDK_LIB_PATH, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of DXSDK_LIB_PATH, 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 DXSDK_LIB_PATH, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    DXSDK_LIB_PATH="`cd "$path"; $THEPWDCMD`"
   fi
 
 
@@ -17510,17 +17795,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$DXSDK_INCLUDE_PATH"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of DXSDK_INCLUDE_PATH, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of DXSDK_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of DXSDK_INCLUDE_PATH, 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 DXSDK_INCLUDE_PATH, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    DXSDK_INCLUDE_PATH="`cd "$path"; $THEPWDCMD`"
   fi
 
 
@@ -28199,6 +28487,8 @@
 
 fi
 
+
+
 # Restore old path without tools dir
 PATH="$OLD_PATH"
 
@@ -30828,17 +31118,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$with_freetype"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of with_freetype, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of with_freetype, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of with_freetype, 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 with_freetype, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    with_freetype="`cd "$path"; $THEPWDCMD`"
   fi
 
 	    FREETYPE2_LIBS="-L$with_freetype/lib -lfreetype"
@@ -31127,17 +31420,20 @@
   else
     # We're on a posix platform. Hooray! :)
     path="$FREETYPELOCATION"
-
-    if test ! -f "$path" && test ! -d "$path"; then
-      as_fn_error $? "The path of FREETYPELOCATION, which resolves as \"$path\", is not found." "$LINENO" 5
-    fi
-
     has_space=`$ECHO "$path" | $GREP " "`
     if test "x$has_space" != x; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FREETYPELOCATION, which resolves as \"$path\", is invalid." >&5
 $as_echo "$as_me: The path of FREETYPELOCATION, 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 FREETYPELOCATION, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    FREETYPELOCATION="`cd "$path"; $THEPWDCMD`"
   fi
 
 	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype in some standard windows locations" >&5
@@ -32664,192 +32960,183 @@
     SJAVAC_SERVER_JAVA=""
     # Hotspot specific options.
 
-    # Test if -verbosegc is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -verbosegc to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$JAVA -verbosegc -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$JAVA -verbosegc -version 2>&1 | grep " version \""`
+    $ECHO "Check if jvm arg is ok: -verbosegc" >&5
+    $ECHO "Command: $JAVA -verbosegc -version" >&5
+    OUTPUT=`$JAVA -verbosegc -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -verbosegc"
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
     fi
 
     # JRockit specific options.
 
-    # Test if -Xverbose:gc is a valid argument to $JAVA (often is $JAVA passed as $JAVA)
-    # If so, then append -Xverbose:gc to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$JAVA -Xverbose:gc -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$JAVA -Xverbose:gc -version 2>&1 | grep " version \""`
+    $ECHO "Check if jvm arg is ok: -Xverbose:gc" >&5
+    $ECHO "Command: $JAVA -Xverbose:gc -version" >&5
+    OUTPUT=`$JAVA -Xverbose:gc -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xverbose:gc"
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
     fi
 
     SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA"
 fi
 
 
-
-# Check whether --with-sjavac-server-cores was given.
-if test "${with_sjavac_server_cores+set}" = set; then :
-  withval=$with_sjavac_server_cores;
-fi
-
-if test "x$with_sjavac_server_cores" != x; then
-    SJAVAC_SERVER_CORES="$with_sjavac_server_cores"
-else
-    if test "$NUM_CORES" -gt 16; then
-        # We set this arbitrary limit because we want to limit the heap
-        # size of the javac server.
-        # In the future we will make the javac compilers in the server
-        # share more and more state, thus enabling us to use more and
-        # more concurrent threads in the server.
-        SJAVAC_SERVER_CORES="16"
-    else
-        SJAVAC_SERVER_CORES="$NUM_CORES"
-    fi
-
-    if test "$MEMORY_SIZE" -gt "17000"; then
-        MAX_HEAP_MEM=10000
-
-    # Test if -d64 is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -d64 to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep " version \""`
+if test "$MEMORY_SIZE" -gt "2500"; then
+
+    $ECHO "Check if jvm arg is ok: -d64" >&5
+    $ECHO "Command: $SJAVAC_SERVER_JAVA -d64 -version" >&5
+    OUTPUT=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -d64"
-    fi
-
-
-    # Test if -Xms10G -Xmx10G is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -Xms10G -Xmx10G to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms10G -Xmx10G -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms10G -Xmx10G -version 2>&1 | grep " version \""`
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
+    fi
+
+    if test "$JVM_ARG_OK" = true; then
+        JVM_64BIT=true
+	JVM_ARG_OK=false
+    fi
+    fi
+
+if test "$JVM_64BIT" = true; then
+    if test "$MEMORY_SIZE" -gt "17000"; then
+
+    $ECHO "Check if jvm arg is ok: -Xms10G -Xmx10G" >&5
+    $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms10G -Xmx10G -version" >&5
+    OUTPUT=`$SJAVAC_SERVER_JAVA -Xms10G -Xmx10G -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms10G -Xmx10G"
-    fi
-
-    elif test "$MEMORY_SIZE" -gt "10000"; then
-        MAX_HEAP_MEM=6000
-
-    # Test if -d64 is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -d64 to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -d64"
-    fi
-
-
-    # Test if -Xms6G -Xmx6G is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -Xms6G -Xmx6G to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms6G -Xmx6G -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms6G -Xmx6G -version 2>&1 | grep " version \""`
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
+    fi
+
+    fi
+    if test "$MEMORY_SIZE" -gt "10000" && test "$JVM_ARG_OK" = false; then
+
+    $ECHO "Check if jvm arg is ok: -Xms6G -Xmx6G" >&5
+    $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms6G -Xmx6G -version" >&5
+    OUTPUT=`$SJAVAC_SERVER_JAVA -Xms6G -Xmx6G -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms6G -Xmx6G"
-    fi
-
-    elif test "$MEMORY_SIZE" -gt "5000"; then
-        MAX_HEAP_MEM=3000
-
-    # Test if -d64 is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -d64 to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -d64"
-    fi
-
-
-    # Test if -Xms1G -Xmx3G is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -Xms1G -Xmx3G to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx3G -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx3G -version 2>&1 | grep " version \""`
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
+    fi
+
+    fi
+    if test "$MEMORY_SIZE" -gt "5000" && test "$JVM_ARG_OK" = false; then
+
+    $ECHO "Check if jvm arg is ok: -Xms1G -Xmx3G" >&5
+    $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms1G -Xmx3G -version" >&5
+    OUTPUT=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx3G -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms1G -Xmx3G"
-    fi
-
-    elif test "$MEMORY_SIZE" -gt "3800"; then
-        MAX_HEAP_MEM=2500
-
-    # Test if -Xms1G -Xmx2500M is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -Xms1G -Xmx2500M to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx2500M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx2500M -version 2>&1 | grep " version \""`
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
+    fi
+
+    fi
+    if test "$MEMORY_SIZE" -gt "3800" && test "$JVM_ARG_OK" = false; then
+
+    $ECHO "Check if jvm arg is ok: -Xms1G -Xmx2500M" >&5
+    $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms1G -Xmx2500M -version" >&5
+    OUTPUT=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx2500M -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms1G -Xmx2500M"
-    fi
-
-    elif test "$MEMORY_SIZE" -gt "1900"; then
-        MAX_HEAP_MEM=1200
-
-    # Test if -Xms700M -Xmx1400M is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -Xms700M -Xmx1400M to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms700M -Xmx1400M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms700M -Xmx1400M -version 2>&1 | grep " version \""`
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
+    fi
+
+    fi
+fi
+if test "$MEMORY_SIZE" -gt "2500" && test "$JVM_ARG_OK" = false; then
+
+    $ECHO "Check if jvm arg is ok: -Xms1000M -Xmx1500M" >&5
+    $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms1000M -Xmx1500M -version" >&5
+    OUTPUT=`$SJAVAC_SERVER_JAVA -Xms1000M -Xmx1500M -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms700M -Xmx1400M"
-    fi
-
-    elif test "$MEMORY_SIZE" -gt "1000"; then
-        MAX_HEAP_MEM=900
-
-    # Test if -Xms400M -Xmx1100M is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -Xms400M -Xmx1100M to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms400M -Xmx1100M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms400M -Xmx1100M -version 2>&1 | grep " version \""`
+        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms1000M -Xmx1500M"
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
+    fi
+
+fi
+if test "$MEMORY_SIZE" -gt "1000" && test "$JVM_ARG_OK" = false; then
+
+    $ECHO "Check if jvm arg is ok: -Xms400M -Xmx1100M" >&5
+    $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms400M -Xmx1100M -version" >&5
+    OUTPUT=`$SJAVAC_SERVER_JAVA -Xms400M -Xmx1100M -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms400M -Xmx1100M"
-    fi
-
-    else
-        MAX_HEAP_MEM=512
-
-    # Test if -Xms256M -Xmx512M is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -Xms256M -Xmx512M to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -Xms256M -Xmx512M -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -Xms256M -Xmx512M -version 2>&1 | grep " version \""`
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
+    fi
+
+fi
+if test "$JVM_ARG_OK" = false; then
+
+    $ECHO "Check if jvm arg is ok: -Xms256M -Xmx512M" >&5
+    $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms256M -Xmx512M -version" >&5
+    OUTPUT=`$SJAVAC_SERVER_JAVA -Xms256M -Xmx512M -version 2>&1`
+    FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
+    FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
     if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
         SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms256M -Xmx512M"
-    fi
-
-    fi
-
-
-    # Test if -XX:PermSize=32m is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -XX:PermSize=32m to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -XX:PermSize=32m -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -XX:PermSize=32m -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -XX:PermSize=32m"
-    fi
-
-
-    # Test if -XX:MaxPermSize=160m is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -XX:MaxPermSize=160m to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -XX:MaxPermSize=160m -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -XX:MaxPermSize=160m -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -XX:MaxPermSize=160m"
-    fi
-
-
-    # Test if -XX:ThreadStackSize=$STACK_SIZE is a valid argument to $SJAVAC_SERVER_JAVA (often is $JAVA passed as $SJAVAC_SERVER_JAVA)
-    # If so, then append -XX:ThreadStackSize=$STACK_SIZE to SJAVAC_SERVER_JAVA
-    FOUND_WARN=`$SJAVAC_SERVER_JAVA -XX:ThreadStackSize=$STACK_SIZE -version 2>&1 | grep -i warn`
-    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -XX:ThreadStackSize=$STACK_SIZE -version 2>&1 | grep " version \""`
-    if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-        SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -XX:ThreadStackSize=$STACK_SIZE"
-    fi
-
-
-    MAX_COMPILERS_IN_HEAP=`expr $MAX_HEAP_MEM / 501`
-    if test "$SJAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking if number of server cores must be reduced" >&5
-$as_echo_n "checking if number of server cores must be reduced... " >&6; }
-        SJAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP"
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB" >&5
-$as_echo "yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB" >&6; }
-    fi
-fi
-
+	JVM_ARG_OK=true
+    else
+	$ECHO "Arg failed:" >&5
+	$ECHO "$OUTPUT" >&5
+	JVM_ARG_OK=false
+    fi
+
+fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use sjavac" >&5
 $as_echo_n "checking whether to use sjavac... " >&6; }
--- a/common/autoconf/spec.gmk.in	Wed May 29 10:16:32 2013 -0700
+++ b/common/autoconf/spec.gmk.in	Wed Jul 05 18:57:02 2017 +0200
@@ -528,6 +528,8 @@
 OBJCOPY:=@OBJCOPY@
 SETFILE:=@SETFILE@
 XATTR:=@XATTR@
+JT_HOME:=@JT_HOME@
+JTREGEXE:=@JTREGEXE@
 
 FIXPATH:=@FIXPATH@
 
--- a/common/autoconf/toolchain.m4	Wed May 29 10:16:32 2013 -0700
+++ b/common/autoconf/toolchain.m4	Wed Jul 05 18:57:02 2017 +0200
@@ -479,6 +479,8 @@
    BASIC_FIXUP_EXECUTABLE(LIPO)
 fi
 
+TOOLCHAIN_SETUP_JTREG
+
 # Restore old path without tools dir
 PATH="$OLD_PATH"
 ])
@@ -1089,3 +1091,29 @@
     [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
 ])
+
+# Setup the JTREG paths 
+AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG], 
+[ 
+  AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg], 
+  [Regression Test Harness @<:@probed@:>@])]) 
+ 
+  AC_MSG_CHECKING([for JTReg Regression Test Harness]) 
+ 
+  if test "x$with_jtreg" != x; then 
+    JT_HOME="$with_jtreg"
+    BASIC_FIXUP_PATH([JT_HOME])
+    AC_MSG_RESULT($JT_HOME)
+ 
+    # jtreg win32 script works for everybody 
+    JTREGEXE="$JT_HOME/win32/bin/jtreg"
+    if test ! -f "$JTREGEXE"; then
+      AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
+    fi
+  else 
+    AC_MSG_RESULT(no)
+  fi 
+ 
+  AC_SUBST(JT_HOME) 
+  AC_SUBST(JTREGEXE) 
+])
--- a/corba/.hgtags	Wed May 29 10:16:32 2013 -0700
+++ b/corba/.hgtags	Wed Jul 05 18:57:02 2017 +0200
@@ -212,3 +212,4 @@
 4e3a881ebb1ee96ce0872508b0066d74f310dbfa jdk8-b88
 fe4150590ee597f4e125fea950aa3b352622cc2d jdk8-b89
 c8286839d0df04aba819ec4bef12b86babccf30e jdk8-b90
+8f7ffb296385f85a4a6d53f9f2d4a7b13a8fa1ff jdk8-b91
--- a/hotspot/.hgtags	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/.hgtags	Wed Jul 05 18:57:02 2017 +0200
@@ -343,3 +343,5 @@
 69494caf57908ba2c8efa9eaaa472b4d1875588a hs25-b32
 1ae0472ff3a0117b5b019d380ad59fface2fde14 jdk8-b90
 b19517cecc2e91636d7c16ba2f35e3d3dc628099 hs25-b33
+7cbdf0e3725c0c56a2ff7540fc70b6d4b5890d04 jdk8-b91
+38da9f4f67096745f851318d792d6468aa1f6cf8 hs25-b34
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/amd64/AMD64CFrame.java	Wed May 29 10:16:32 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +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.
- *
- */
-
-package sun.jvm.hotspot.debugger.cdbg.basic.amd64;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.amd64.*;
-import sun.jvm.hotspot.debugger.cdbg.*;
-import sun.jvm.hotspot.debugger.cdbg.basic.*;
-
-/** Basic AMD64 frame functionality providing sender() functionality. */
-
-public class AMD64CFrame extends BasicCFrame {
-  private Address rbp;
-  private Address pc;
-
-  private static final int ADDRESS_SIZE = 8;
-
-  /** Constructor for topmost frame */
-  public AMD64CFrame(CDebugger dbg, Address rbp, Address pc) {
-    super(dbg);
-    this.rbp = rbp;
-    this.pc  = pc;
-  }
-
-  public CFrame sender(ThreadProxy thread) {
-    AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
-    Address rsp = context.getRegisterAsAddress(AMD64ThreadContext.RSP);
-
-    if ( (rbp == null) || rbp.lessThan(rsp) ) {
-      return null;
-    }
-
-    Address nextRBP = rbp.getAddressAt( 0 * ADDRESS_SIZE);
-    if (nextRBP == null) {
-      return null;
-    }
-    Address nextPC  = rbp.getAddressAt( 1 * ADDRESS_SIZE);
-    if (nextPC == null) {
-      return null;
-    }
-    return new AMD64CFrame(dbg(), nextRBP, nextPC);
-  }
-
-  public Address pc() {
-    return pc;
-  }
-
-  public Address localVariableBase() {
-    return rbp;
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/x86/X86CFrame.java	Wed May 29 10:16:32 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- *
- */
-
-package sun.jvm.hotspot.debugger.cdbg.basic.x86;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.x86.*;
-import sun.jvm.hotspot.debugger.cdbg.*;
-import sun.jvm.hotspot.debugger.cdbg.basic.*;
-
-/** Basic X86 frame functionality providing sender() functionality. */
-
-public class X86CFrame extends BasicCFrame {
-  private Address ebp;
-  private Address pc;
-
-  private static final int ADDRESS_SIZE = 4;
-
-  /** Constructor for topmost frame */
-  public X86CFrame(CDebugger dbg, Address ebp, Address pc) {
-    super(dbg);
-    this.ebp = ebp;
-    this.pc  = pc;
-  }
-
-  public CFrame sender(ThreadProxy thread) {
-    X86ThreadContext context = (X86ThreadContext) thread.getContext();
-    Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP);
-
-    if ( (ebp == null) || ebp.lessThan(esp) ) {
-      return null;
-    }
-
-    Address nextEBP = ebp.getAddressAt( 0 * ADDRESS_SIZE);
-    if (nextEBP == null) {
-      return null;
-    }
-    Address nextPC  = ebp.getAddressAt( 1 * ADDRESS_SIZE);
-    if (nextPC == null) {
-      return null;
-    }
-    return new X86CFrame(dbg(), nextEBP, nextPC);
-  }
-
-  public Address pc() {
-    return pc;
-  }
-
-  public Address localVariableBase() {
-    return ebp;
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java	Wed Jul 05 18:57:02 2017 +0200
@@ -28,10 +28,10 @@
 import java.util.*;
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.debugger.cdbg.*;
-import sun.jvm.hotspot.debugger.cdbg.basic.x86.*;
-import sun.jvm.hotspot.debugger.cdbg.basic.amd64.*;
 import sun.jvm.hotspot.debugger.x86.*;
 import sun.jvm.hotspot.debugger.amd64.*;
+import sun.jvm.hotspot.debugger.windows.x86.*;
+import sun.jvm.hotspot.debugger.windows.amd64.*;
 import sun.jvm.hotspot.utilities.AddressOps;
 
 class WindbgCDebugger implements CDebugger {
@@ -75,14 +75,14 @@
       if (ebp == null) return null;
       Address pc  = context.getRegisterAsAddress(X86ThreadContext.EIP);
       if (pc == null) return null;
-      return new X86CFrame(this, ebp, pc);
+      return new WindowsX86CFrame(dbg, ebp, pc);
     } else if (dbg.getCPU().equals("amd64")) {
       AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
       Address rbp = context.getRegisterAsAddress(AMD64ThreadContext.RBP);
       if (rbp == null) return null;
       Address pc  = context.getRegisterAsAddress(AMD64ThreadContext.RIP);
       if (pc == null) return null;
-      return new AMD64CFrame(this, rbp, pc);
+      return new WindowsAMD64CFrame(dbg, rbp, pc);
     } else {
       // unsupported CPU!
       return null;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/amd64/WindowsAMD64CFrame.java	Wed Jul 05 18:57:02 2017 +0200
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ *
+ */
+
+package sun.jvm.hotspot.debugger.windows.amd64;
+
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.amd64.*;
+import sun.jvm.hotspot.debugger.cdbg.*;
+import sun.jvm.hotspot.debugger.cdbg.basic.*;
+import sun.jvm.hotspot.debugger.windbg.*;
+
+public class WindowsAMD64CFrame extends BasicCFrame {
+  private Address rbp;
+  private Address pc;
+
+  private static final int ADDRESS_SIZE = 8;
+
+  /** Constructor for topmost frame */
+  public WindowsAMD64CFrame(WindbgDebugger dbg, Address rbp, Address pc) {
+    super(dbg.getCDebugger());
+    this.rbp = rbp;
+    this.pc  = pc;
+    this.dbg = dbg;
+  }
+
+  public CFrame sender(ThreadProxy thread) {
+    AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
+    Address rsp = context.getRegisterAsAddress(AMD64ThreadContext.RSP);
+
+    if ( (rbp == null) || rbp.lessThan(rsp) ) {
+      return null;
+    }
+
+    // Check alignment of rbp
+    if ( dbg.getAddressValue(rbp) % ADDRESS_SIZE != 0) {
+        return null;
+    }
+
+    Address nextRBP = rbp.getAddressAt( 0 * ADDRESS_SIZE);
+    if (nextRBP == null || nextRBP.lessThanOrEqual(rbp)) {
+      return null;
+    }
+    Address nextPC  = rbp.getAddressAt( 1 * ADDRESS_SIZE);
+    if (nextPC == null) {
+      return null;
+    }
+    return new WindowsAMD64CFrame(dbg, nextRBP, nextPC);
+  }
+
+  public Address pc() {
+    return pc;
+  }
+
+  public Address localVariableBase() {
+    return rbp;
+  }
+
+  private WindbgDebugger dbg;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java	Wed Jul 05 18:57:02 2017 +0200
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2001, 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.
+ *
+ */
+
+package sun.jvm.hotspot.debugger.windows.x86;
+
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.x86.*;
+import sun.jvm.hotspot.debugger.cdbg.*;
+import sun.jvm.hotspot.debugger.cdbg.basic.*;
+import sun.jvm.hotspot.debugger.windbg.*;
+
+public class WindowsX86CFrame extends BasicCFrame {
+  private Address ebp;
+  private Address pc;
+
+  private static final int ADDRESS_SIZE = 4;
+
+  /** Constructor for topmost frame */
+  public WindowsX86CFrame(WindbgDebugger dbg, Address ebp, Address pc) {
+    super(dbg.getCDebugger());
+    this.ebp = ebp;
+    this.pc  = pc;
+    this.dbg = dbg;
+  }
+
+  public CFrame sender(ThreadProxy thread) {
+    X86ThreadContext context = (X86ThreadContext) thread.getContext();
+    Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP);
+
+    if ( (ebp == null) || ebp.lessThan(esp) ) {
+      return null;
+    }
+
+    // Check alignment of ebp
+    if ( dbg.getAddressValue(ebp) % ADDRESS_SIZE != 0) {
+        return null;
+    }
+
+    Address nextEBP = ebp.getAddressAt( 0 * ADDRESS_SIZE);
+    if (nextEBP == null || nextEBP.lessThanOrEqual(ebp)) {
+      return null;
+    }
+    Address nextPC  = ebp.getAddressAt( 1 * ADDRESS_SIZE);
+    if (nextPC == null) {
+      return null;
+    }
+    return new WindowsX86CFrame(dbg, nextEBP, nextPC);
+  }
+
+  public Address pc() {
+    return pc;
+  }
+
+  public Address localVariableBase() {
+    return ebp;
+  }
+
+  private WindbgDebugger dbg;
+}
--- a/hotspot/make/bsd/makefiles/arm.make	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/make/bsd/makefiles/arm.make	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 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
@@ -24,6 +24,8 @@
 
 Obj_Files += bsd_arm.o
 
-LIBS += $(EXT_LIBS_PATH)/sflt_glibc.a 
+ifneq ($(EXT_LIBS_PATH),)
+  LIBS += $(EXT_LIBS_PATH)/sflt_glibc.a 
+endif
 
 CFLAGS += -DVM_LITTLE_ENDIAN
--- a/hotspot/make/hotspot_version	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/make/hotspot_version	Wed Jul 05 18:57:02 2017 +0200
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=25
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=33
+HS_BUILD_NUMBER=34
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=8
--- a/hotspot/make/linux/makefiles/arm.make	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/make/linux/makefiles/arm.make	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 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
@@ -24,6 +24,8 @@
 
 Obj_Files += linux_arm.o
 
-LIBS += $(EXT_LIBS_PATH)/sflt_glibc.a 
+ifneq ($(EXT_LIBS_PATH),)
+  LIBS += $(EXT_LIBS_PATH)/sflt_glibc.a 
+endif
 
 CFLAGS += -DVM_LITTLE_ENDIAN
--- a/hotspot/make/linux/makefiles/jsig.make	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/make/linux/makefiles/jsig.make	Wed Jul 05 18:57:02 2017 +0200
@@ -54,7 +54,7 @@
 $(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
 	@echo Making signal interposition lib...
 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
-                         $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) -o $@ $< -ldl
+                         $(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) $@
--- a/hotspot/make/linux/makefiles/saproc.make	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/make/linux/makefiles/saproc.make	Wed Jul 05 18:57:02 2017 +0200
@@ -92,6 +92,7 @@
 	           $(SASRCFILES)                                        \
 	           $(SA_LFLAGS)                                         \
 	           $(SA_DEBUG_CFLAGS)                                   \
+	           $(EXTRA_CFLAGS)                                      \
 	           -o $@                                                \
 	           -lthread_db
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
--- a/hotspot/make/sa.files	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/make/sa.files	Wed Jul 05 18:57:02 2017 +0200
@@ -48,8 +48,6 @@
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/*.java \
-$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/x86/*.java \
-$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/amd64/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/dummy/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/linux/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/linux/amd64/*.java \
@@ -70,6 +68,8 @@
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/amd64/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/x86/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windows/x86/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windows/amd64/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/g1/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/parallelScavenge/*.java \
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -1498,27 +1498,29 @@
     __ movptr(elem_klass, elem_klass_addr); // query the object klass
     generate_type_check(elem_klass, ckoff_arg, ckval_arg, temp,
                         &L_store_element, NULL);
-      // (On fall-through, we have failed the element type check.)
+    // (On fall-through, we have failed the element type check.)
     // ======== end loop ========
 
     // It was a real error; we must depend on the caller to finish the job.
     // Register "count" = -1 * number of *remaining* oops, length_arg = *total* oops.
     // Emit GC store barriers for the oops we have copied (length_arg + count),
     // and report their number to the caller.
+    assert_different_registers(to, count, rax);
+    Label L_post_barrier;
     __ addl(count, length_arg);         // transfers = (length - remaining)
     __ movl2ptr(rax, count);            // save the value
-    __ notptr(rax);                     // report (-1^K) to caller
-    __ movptr(to, to_arg);              // reload
-    assert_different_registers(to, count, rax);
-    gen_write_ref_array_post_barrier(to, count);
-    __ jmpb(L_done);
+    __ notptr(rax);                     // report (-1^K) to caller (does not affect flags)
+    __ jccb(Assembler::notZero, L_post_barrier);
+    __ jmp(L_done); // K == 0, nothing was copied, skip post barrier
 
     // Come here on success only.
     __ BIND(L_do_card_marks);
+    __ xorptr(rax, rax);                // return 0 on success
     __ movl2ptr(count, length_arg);
-    __ movptr(to, to_arg);                // reload
+
+    __ BIND(L_post_barrier);
+    __ movptr(to, to_arg);              // reload
     gen_write_ref_array_post_barrier(to, count);
-    __ xorptr(rax, rax);                  // return 0 on success
 
     // Common exit point (success or failure).
     __ BIND(L_done);
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -1217,27 +1217,28 @@
   //
   //  Input:
   //     start    - register containing starting address of destination array
-  //     end      - register containing ending address of destination array
+  //     count    - elements count
   //     scratch  - scratch register
   //
   //  The input registers are overwritten.
-  //  The ending address is inclusive.
-  void  gen_write_ref_array_post_barrier(Register start, Register end, Register scratch) {
-    assert_different_registers(start, end, scratch);
+  //
+  void  gen_write_ref_array_post_barrier(Register start, Register count, Register scratch) {
+    assert_different_registers(start, count, scratch);
     BarrierSet* bs = Universe::heap()->barrier_set();
     switch (bs->kind()) {
       case BarrierSet::G1SATBCT:
       case BarrierSet::G1SATBCTLogging:
-
         {
-          __ pusha();                      // push registers (overkill)
-          // must compute element count unless barrier set interface is changed (other platforms supply count)
-          assert_different_registers(start, end, scratch);
-          __ lea(scratch, Address(end, BytesPerHeapOop));
-          __ subptr(scratch, start);               // subtract start to get #bytes
-          __ shrptr(scratch, LogBytesPerHeapOop);  // convert to element count
-          __ mov(c_rarg0, start);
-          __ mov(c_rarg1, scratch);
+          __ pusha();             // push registers (overkill)
+          if (c_rarg0 == count) { // On win64 c_rarg0 == rcx
+            assert_different_registers(c_rarg1, start);
+            __ mov(c_rarg1, count);
+            __ mov(c_rarg0, start);
+          } else {
+            assert_different_registers(c_rarg0, count);
+            __ mov(c_rarg0, start);
+            __ mov(c_rarg1, count);
+          }
           __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post), 2);
           __ popa();
         }
@@ -1249,22 +1250,16 @@
           assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
 
           Label L_loop;
-
-           __ shrptr(start, CardTableModRefBS::card_shift);
-           __ addptr(end, BytesPerHeapOop);
-           __ shrptr(end, CardTableModRefBS::card_shift);
-           __ subptr(end, start); // number of bytes to copy
-
-          intptr_t disp = (intptr_t) ct->byte_map_base;
-          if (Assembler::is_simm32(disp)) {
-            Address cardtable(noreg, noreg, Address::no_scale, disp);
-            __ lea(scratch, cardtable);
-          } else {
-            ExternalAddress cardtable((address)disp);
-            __ lea(scratch, cardtable);
-          }
-
-          const Register count = end; // 'end' register contains bytes count now
+          const Register end = count;
+
+          __ leaq(end, Address(start, count, TIMES_OOP, 0));  // end == start+count*oop_size
+          __ subptr(end, BytesPerHeapOop); // end - 1 to make inclusive
+          __ shrptr(start, CardTableModRefBS::card_shift);
+          __ shrptr(end,   CardTableModRefBS::card_shift);
+          __ subptr(end, start); // end --> cards count
+
+          int64_t disp = (int64_t) ct->byte_map_base;
+          __ mov64(scratch, disp);
           __ addptr(start, scratch);
         __ BIND(L_loop);
           __ movb(Address(start, count, Address::times_1), 0);
@@ -1916,8 +1911,7 @@
 
   __ BIND(L_exit);
     if (is_oop) {
-      __ leaq(end_to, Address(saved_to, dword_count, Address::times_4, -4));
-      gen_write_ref_array_post_barrier(saved_to, end_to, rax);
+      gen_write_ref_array_post_barrier(saved_to, dword_count, rax);
     }
     restore_arg_regs();
     inc_counter_np(SharedRuntime::_jint_array_copy_ctr); // Update counter after rscratch1 is free
@@ -2012,12 +2006,10 @@
     // Copy in multi-bytes chunks
     copy_bytes_backward(from, to, qword_count, rax, L_copy_bytes, L_copy_8_bytes);
 
-   __ bind(L_exit);
-     if (is_oop) {
-       Register end_to = rdx;
-       __ leaq(end_to, Address(to, dword_count, Address::times_4, -4));
-       gen_write_ref_array_post_barrier(to, end_to, rax);
-     }
+  __ BIND(L_exit);
+    if (is_oop) {
+      gen_write_ref_array_post_barrier(to, dword_count, rax);
+    }
     restore_arg_regs();
     inc_counter_np(SharedRuntime::_jint_array_copy_ctr); // Update counter after rscratch1 is free
     __ xorptr(rax, rax); // return 0
@@ -2055,6 +2047,7 @@
     const Register end_from    = from; // source array end address
     const Register end_to      = rcx;  // destination array end address
     const Register saved_to    = to;
+    const Register saved_count = r11;
     // End pointers are inclusive, and if count is not zero they point
     // to the last unit copied:  end_to[0] := end_from[0]
 
@@ -2072,6 +2065,8 @@
                       // r9 and r10 may be used to save non-volatile registers
     // 'from', 'to' and 'qword_count' are now valid
     if (is_oop) {
+      // Save to and count for store barrier
+      __ movptr(saved_count, qword_count);
       // no registers are destroyed by this call
       gen_write_ref_array_pre_barrier(to, qword_count, dest_uninitialized);
     }
@@ -2104,7 +2099,7 @@
 
     if (is_oop) {
     __ BIND(L_exit);
-      gen_write_ref_array_post_barrier(saved_to, end_to, rax);
+      gen_write_ref_array_post_barrier(saved_to, saved_count, rax);
     }
     restore_arg_regs();
     if (is_oop) {
@@ -2187,8 +2182,7 @@
 
     if (is_oop) {
     __ BIND(L_exit);
-      __ lea(rcx, Address(to, saved_count, Address::times_8, -8));
-      gen_write_ref_array_post_barrier(to, rcx, rax);
+      gen_write_ref_array_post_barrier(to, saved_count, rax);
     }
     restore_arg_regs();
     if (is_oop) {
@@ -2375,20 +2369,20 @@
     // Register rdx = -1 * number of *remaining* oops, r14 = *total* oops.
     // Emit GC store barriers for the oops we have copied (r14 + rdx),
     // and report their number to the caller.
-    assert_different_registers(rax, r14_length, count, to, end_to, rcx);
-    __ lea(end_to, to_element_addr);
-    __ addptr(end_to, -heapOopSize);      // make an inclusive end pointer
-    gen_write_ref_array_post_barrier(to, end_to, rscratch1);
-    __ movptr(rax, r14_length);           // original oops
-    __ addptr(rax, count);                // K = (original - remaining) oops
-    __ notptr(rax);                       // report (-1^K) to caller
-    __ jmp(L_done);
+    assert_different_registers(rax, r14_length, count, to, end_to, rcx, rscratch1);
+    Label L_post_barrier;
+    __ addptr(r14_length, count);     // K = (original - remaining) oops
+    __ movptr(rax, r14_length);       // save the value
+    __ notptr(rax);                   // report (-1^K) to caller (does not affect flags)
+    __ jccb(Assembler::notZero, L_post_barrier);
+    __ jmp(L_done); // K == 0, nothing was copied, skip post barrier
 
     // Come here on success only.
     __ BIND(L_do_card_marks);
-    __ addptr(end_to, -heapOopSize);         // make an inclusive end pointer
-    gen_write_ref_array_post_barrier(to, end_to, rscratch1);
-    __ xorptr(rax, rax);                  // return 0 on success
+    __ xorptr(rax, rax);              // return 0 on success
+
+    __ BIND(L_post_barrier);
+    gen_write_ref_array_post_barrier(to, r14_length, rscratch1);
 
     // Common exit point (success or failure).
     __ BIND(L_done);
--- a/hotspot/src/share/tools/hsdis/hsdis.c	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/tools/hsdis/hsdis.c	Wed Jul 05 18:57:02 2017 +0200
@@ -27,6 +27,7 @@
    HotSpot PrintAssembly option.
 */
 
+#include <config.h> /* required by bfd.h */
 #include <libiberty.h>
 #include <bfd.h>
 #include <dis-asm.h>
--- a/hotspot/src/share/vm/c1/c1_Compiler.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -77,30 +77,42 @@
 }
 
 
-BufferBlob* Compiler::build_buffer_blob() {
+BufferBlob* Compiler::get_buffer_blob(ciEnv* env) {
+  // Allocate buffer blob once at startup since allocation for each
+  // compilation seems to be too expensive (at least on Intel win32).
+  BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
+  if (buffer_blob != NULL) {
+    return buffer_blob;
+  }
+
   // setup CodeBuffer.  Preallocate a BufferBlob of size
   // NMethodSizeLimit plus some extra space for constants.
   int code_buffer_size = Compilation::desired_max_code_buffer_size() +
     Compilation::desired_max_constant_size();
-  BufferBlob* blob = BufferBlob::create("Compiler1 temporary CodeBuffer",
-                                        code_buffer_size);
-  guarantee(blob != NULL, "must create initial code buffer");
-  return blob;
+
+  buffer_blob = BufferBlob::create("Compiler1 temporary CodeBuffer",
+                                   code_buffer_size);
+  if (buffer_blob == NULL) {
+    CompileBroker::handle_full_code_cache();
+    env->record_failure("CodeCache is full");
+  } else {
+    CompilerThread::current()->set_buffer_blob(buffer_blob);
+  }
+
+  return buffer_blob;
 }
 
 
 void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) {
-  // Allocate buffer blob once at startup since allocation for each
-  // compilation seems to be too expensive (at least on Intel win32).
-  BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
+  BufferBlob* buffer_blob = Compiler::get_buffer_blob(env);
   if (buffer_blob == NULL) {
-    buffer_blob = build_buffer_blob();
-    CompilerThread::current()->set_buffer_blob(buffer_blob);
+    return;
   }
 
   if (!is_initialized()) {
     initialize();
   }
+
   // invoke compilation
   {
     // We are nested here because we need for the destructor
--- a/hotspot/src/share/vm/c1/c1_Compiler.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/c1/c1_Compiler.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -46,7 +46,7 @@
 
   virtual bool is_c1()                           { return true; };
 
-  BufferBlob* build_buffer_blob();
+  BufferBlob* get_buffer_blob(ciEnv* env);
 
   // Missing feature tests
   virtual bool supports_native()                 { return true; }
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -1719,15 +1719,28 @@
     coll->set_annotation(id);
 
     if (id == AnnotationCollector::_sun_misc_Contended) {
+      // @Contended can optionally specify the contention group.
+      //
+      // Contended group defines the equivalence class over the fields:
+      // the fields within the same contended group are not treated distinct.
+      // The only exception is default group, which does not incur the
+      // equivalence. Naturally, contention group for classes is meaningless.
+      //
+      // While the contention group is specified as String, annotation
+      // values are already interned, and we might as well use the constant
+      // pool index as the group tag.
+      //
+      u2 group_index = 0; // default contended group
       if (count == 1
           && s_size == (index - index0)  // match size
           && s_tag_val == *(abase + tag_off)
           && member == vmSymbols::value_name()) {
-        u2 group_index = Bytes::get_Java_u2(abase + s_con_off);
-        coll->set_contended_group(group_index);
-      } else {
-        coll->set_contended_group(0); // default contended group
+        group_index = Bytes::get_Java_u2(abase + s_con_off);
+        if (_cp->symbol_at(group_index)->utf8_length() == 0) {
+          group_index = 0; // default contended group
+        }
       }
+      coll->set_contended_group(group_index);
     }
   }
 }
@@ -3108,10 +3121,6 @@
                                     FieldLayoutInfo* info,
                                     TRAPS) {
 
-  // get the padding width from the option
-  // TODO: Ask VM about specific CPU we are running on
-  int pad_size = ContendedPaddingWidth;
-
   // Field size and offset computation
   int nonstatic_field_size = _super_klass() == NULL ? 0 : _super_klass()->nonstatic_field_size();
   int next_static_oop_offset;
@@ -3124,13 +3133,14 @@
   int next_nonstatic_word_offset;
   int next_nonstatic_short_offset;
   int next_nonstatic_byte_offset;
-  int next_nonstatic_type_offset;
   int first_nonstatic_oop_offset;
-  int first_nonstatic_field_offset;
   int next_nonstatic_field_offset;
   int next_nonstatic_padded_offset;
 
   // Count the contended fields by type.
+  //
+  // We ignore static fields, because @Contended is not supported for them.
+  // The layout code below will also ignore the static fields.
   int nonstatic_contended_count = 0;
   FieldAllocationCount fac_contended;
   for (AllFieldStream fs(_fields, _cp); !fs.done(); fs.next()) {
@@ -3162,16 +3172,17 @@
   next_static_byte_offset     = next_static_short_offset +
                                 ((fac->count[STATIC_SHORT]) * BytesPerShort);
 
-  first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() +
-                                 nonstatic_field_size * heapOopSize;
-
-  // class is contended, pad before all the fields
+  int nonstatic_fields_start  = instanceOopDesc::base_offset_in_bytes() +
+                                nonstatic_field_size * heapOopSize;
+
+  next_nonstatic_field_offset = nonstatic_fields_start;
+
+  // Class is contended, pad before all the fields
   if (parsed_annotations->is_contended()) {
-    first_nonstatic_field_offset += pad_size;
+    next_nonstatic_field_offset += ContendedPaddingWidth;
   }
 
-  next_nonstatic_field_offset = first_nonstatic_field_offset;
-
+  // Compute the non-contended fields count
   unsigned int nonstatic_double_count = fac->count[NONSTATIC_DOUBLE] - fac_contended.count[NONSTATIC_DOUBLE];
   unsigned int nonstatic_word_count   = fac->count[NONSTATIC_WORD]   - fac_contended.count[NONSTATIC_WORD];
   unsigned int nonstatic_short_count  = fac->count[NONSTATIC_SHORT]  - fac_contended.count[NONSTATIC_SHORT];
@@ -3229,6 +3240,7 @@
     compact_fields   = false; // Don't compact fields
   }
 
+  // Rearrange fields for a given allocation style
   if( allocation_style == 0 ) {
     // Fields order: oops, longs/doubles, ints, shorts/chars, bytes, padded fields
     next_nonstatic_oop_offset    = next_nonstatic_field_offset;
@@ -3269,6 +3281,8 @@
   int nonstatic_short_space_offset;
   int nonstatic_byte_space_offset;
 
+  // Try to squeeze some of the fields into the gaps due to
+  // long/double alignment.
   if( nonstatic_double_count > 0 ) {
     int offset = next_nonstatic_double_offset;
     next_nonstatic_double_offset = align_size_up(offset, BytesPerLong);
@@ -3442,7 +3456,7 @@
 
     // if there is at least one contended field, we need to have pre-padding for them
     if (nonstatic_contended_count > 0) {
-      next_nonstatic_padded_offset += pad_size;
+      next_nonstatic_padded_offset += ContendedPaddingWidth;
     }
 
     // collect all contended groups
@@ -3521,7 +3535,7 @@
           // the fields within the same contended group are not inter-padded.
           // The only exception is default group, which does not incur the
           // equivalence, and so requires intra-padding.
-          next_nonstatic_padded_offset += pad_size;
+          next_nonstatic_padded_offset += ContendedPaddingWidth;
         }
 
         fs.set_offset(real_offset);
@@ -3533,7 +3547,7 @@
       // subclass fields and/or adjacent object.
       // If this was the default group, the padding is already in place.
       if (current_group != 0) {
-        next_nonstatic_padded_offset += pad_size;
+        next_nonstatic_padded_offset += ContendedPaddingWidth;
       }
     }
 
@@ -3547,22 +3561,22 @@
   // This helps to alleviate memory contention effects for subclass fields
   // and/or adjacent object.
   if (parsed_annotations->is_contended()) {
-    notaligned_offset += pad_size;
+    notaligned_offset += ContendedPaddingWidth;
   }
 
-  int next_static_type_offset     = align_size_up(next_static_byte_offset, wordSize);
-  int static_field_size           = (next_static_type_offset -
-                                InstanceMirrorKlass::offset_of_static_fields()) / wordSize;
-
-  next_nonstatic_type_offset = align_size_up(notaligned_offset, heapOopSize );
-  nonstatic_field_size = nonstatic_field_size + ((next_nonstatic_type_offset
-                                 - first_nonstatic_field_offset)/heapOopSize);
-
-  next_nonstatic_type_offset = align_size_up(notaligned_offset, wordSize );
-  int instance_size = align_object_size(next_nonstatic_type_offset / wordSize);
+  int nonstatic_fields_end      = align_size_up(notaligned_offset, heapOopSize);
+  int instance_end              = align_size_up(notaligned_offset, wordSize);
+  int static_fields_end         = align_size_up(next_static_byte_offset, wordSize);
+
+  int static_field_size         = (static_fields_end -
+                                   InstanceMirrorKlass::offset_of_static_fields()) / wordSize;
+  nonstatic_field_size          = nonstatic_field_size +
+                                  (nonstatic_fields_end - nonstatic_fields_start) / heapOopSize;
+
+  int instance_size             = align_object_size(instance_end / wordSize);
 
   assert(instance_size == align_object_size(align_size_up(
-         (instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize + ((parsed_annotations->is_contended()) ? pad_size : 0)),
+         (instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize),
           wordSize) / wordSize), "consistent layout helper value");
 
   // Number of non-static oop map blocks allocated at end of klass.
@@ -3576,9 +3590,9 @@
           _fields,
           _cp,
           instance_size,
-          first_nonstatic_field_offset,
-          next_nonstatic_field_offset,
-          next_static_type_offset);
+          nonstatic_fields_start,
+          nonstatic_fields_end,
+          static_fields_end);
   }
 
 #endif
--- a/hotspot/src/share/vm/classfile/symbolTable.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -35,7 +35,6 @@
 #include "oops/oop.inline2.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "utilities/hashtable.inline.hpp"
-#include "utilities/numberSeq.hpp"
 
 // --------------------------------------------------------------------------
 
@@ -451,21 +450,7 @@
 }
 
 void SymbolTable::dump(outputStream* st) {
-  NumberSeq summary;
-  for (int i = 0; i < the_table()->table_size(); ++i) {
-    int count = 0;
-    for (HashtableEntry<Symbol*, mtSymbol>* e = the_table()->bucket(i);
-       e != NULL; e = e->next()) {
-      count++;
-    }
-    summary.add((double)count);
-  }
-  st->print_cr("SymbolTable statistics:");
-  st->print_cr("Number of buckets       : %7d", summary.num());
-  st->print_cr("Average bucket size     : %7.0f", summary.avg());
-  st->print_cr("Variance of bucket size : %7.0f", summary.variance());
-  st->print_cr("Std. dev. of bucket size: %7.0f", summary.sd());
-  st->print_cr("Maximum bucket size     : %7.0f", summary.maximum());
+  the_table()->dump_table(st, "SymbolTable");
 }
 
 
@@ -814,21 +799,7 @@
 }
 
 void StringTable::dump(outputStream* st) {
-  NumberSeq summary;
-  for (int i = 0; i < the_table()->table_size(); ++i) {
-    HashtableEntry<oop, mtSymbol>* p = the_table()->bucket(i);
-    int count = 0;
-    for ( ; p != NULL; p = p->next()) {
-      count++;
-    }
-    summary.add((double)count);
-  }
-  st->print_cr("StringTable statistics:");
-  st->print_cr("Number of buckets       : %7d", summary.num());
-  st->print_cr("Average bucket size     : %7.0f", summary.avg());
-  st->print_cr("Variance of bucket size : %7.0f", summary.variance());
-  st->print_cr("Std. dev. of bucket size: %7.0f", summary.sd());
-  st->print_cr("Maximum bucket size     : %7.0f", summary.maximum());
+  the_table()->dump_table(st, "StringTable");
 }
 
 
--- a/hotspot/src/share/vm/code/codeCache.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/code/codeCache.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -622,6 +622,15 @@
   return (address)_heap->high();
 }
 
+/**
+ * Returns the reverse free ratio. E.g., if 25% (1/4) of the code cache
+ * is free, reverse_free_ratio() returns 4.
+ */
+double CodeCache::reverse_free_ratio() {
+  double unallocated_capacity = (double)(CodeCache::unallocated_capacity() - CodeCacheMinimumFreeSpace);
+  double max_capacity = (double)CodeCache::max_capacity();
+  return max_capacity / unallocated_capacity;
+}
 
 void icache_init();
 
--- a/hotspot/src/share/vm/code/codeCache.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/code/codeCache.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -163,6 +163,7 @@
   static size_t  max_capacity()                  { return _heap->max_capacity(); }
   static size_t  unallocated_capacity()          { return _heap->unallocated_capacity(); }
   static bool    needs_flushing()                { return unallocated_capacity() < CodeCacheFlushingMinimumFreeSpace; }
+  static double  reverse_free_ratio();
 
   static bool needs_cache_clean()                { return _needs_cache_clean; }
   static void set_needs_cache_clean(bool v)      { _needs_cache_clean = v;    }
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -51,14 +51,6 @@
 }
 
 template <class Chunk>
-AdaptiveFreeList<Chunk>::AdaptiveFreeList(Chunk* fc) : FreeList<Chunk>(fc), _hint(0) {
-  init_statistics();
-#ifndef PRODUCT
-  _allocation_stats.set_returned_bytes(size() * HeapWordSize);
-#endif
-}
-
-template <class Chunk>
 void AdaptiveFreeList<Chunk>::initialize() {
   FreeList<Chunk>::initialize();
   set_hint(0);
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -55,7 +55,6 @@
  public:
 
   AdaptiveFreeList();
-  AdaptiveFreeList(Chunk* fc);
 
   using FreeList<Chunk>::assert_proper_lock_protection;
 #ifdef ASSERT
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -153,8 +153,6 @@
       _indexedFreeListParLocks[i] = new Mutex(Mutex::leaf - 1, // == ExpandHeap_lock - 1
                                               "a freelist par lock",
                                               true);
-      if (_indexedFreeListParLocks[i] == NULL)
-        vm_exit_during_initialization("Could not allocate a par lock");
       DEBUG_ONLY(
         _indexedFreeList[i].set_protecting_lock(_indexedFreeListParLocks[i]);
       )
@@ -285,6 +283,7 @@
       _bt.verify_not_unallocated((HeapWord*)fc, fc->size());
       _indexedFreeList[mr.word_size()].return_chunk_at_head(fc);
     }
+    coalBirth(mr.word_size());
   }
   _promoInfo.reset();
   _smallLinearAllocBlock._ptr = NULL;
@@ -1762,7 +1761,7 @@
   }
   ec->set_size(size);
   debug_only(ec->mangleFreed(size));
-  if (size < SmallForDictionary) {
+  if (size < SmallForDictionary && ParallelGCThreads != 0) {
     lock = _indexedFreeListParLocks[size];
   }
   MutexLockerEx x(lock, Mutex::_no_safepoint_check_flag);
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -3381,7 +3381,6 @@
   assert_locked_or_safepoint(Heap_lock);
   bool result = _virtual_space.expand_by(bytes);
   if (result) {
-    HeapWord* old_end = _cmsSpace->end();
     size_t new_word_size =
       heap_word_size(_virtual_space.committed_size());
     MemRegion mr(_cmsSpace->bottom(), new_word_size);
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -485,10 +485,6 @@
     assert(!span.is_empty(), "Empty span could spell trouble");
   }
 
-  void do_object(oop obj) {
-    assert(false, "not to be invoked");
-  }
-
   bool do_object_b(oop obj);
 };
 
@@ -1536,9 +1532,6 @@
     _bit_map(bit_map),
     _par_scan_closure(cl) { }
 
-  void do_object(oop obj) {
-    guarantee(false, "Call do_object_b(oop, MemRegion) instead");
-  }
   bool do_object_b(oop obj) {
     guarantee(false, "Call do_object_b(oop, MemRegion) form instead");
     return false;
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -44,9 +44,6 @@
  public:
   G1CMIsAliveClosure(G1CollectedHeap* g1) : _g1(g1) { }
 
-  void do_object(oop obj) {
-    ShouldNotCallThis();
-  }
   bool do_object_b(oop obj);
 };
 
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -5090,7 +5090,6 @@
   G1CollectedHeap* _g1;
 public:
   G1AlwaysAliveClosure(G1CollectedHeap* g1) : _g1(g1) {}
-  void do_object(oop p) { assert(false, "Do not call."); }
   bool do_object_b(oop p) {
     if (p != NULL) {
       return true;
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -165,7 +165,6 @@
   G1CollectedHeap* _g1;
 public:
   G1STWIsAliveClosure(G1CollectedHeap* g1) : _g1(g1) {}
-  void do_object(oop p) { assert(false, "Do not call."); }
   bool do_object_b(oop p);
 };
 
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -242,11 +242,13 @@
     PerRegionTable* cur = _free_list;
     size_t res = 0;
     while (cur != NULL) {
-      res += sizeof(PerRegionTable);
+      res += cur->mem_size();
       cur = cur->next();
     }
     return res;
   }
+
+  static void test_fl_mem_size();
 };
 
 PerRegionTable* PerRegionTable::_free_list = NULL;
@@ -1149,6 +1151,19 @@
 }
 
 #ifndef PRODUCT
+void PerRegionTable::test_fl_mem_size() {
+  PerRegionTable* dummy = alloc(NULL);
+  free(dummy);
+  guarantee(dummy->mem_size() == fl_mem_size(), "fl_mem_size() does not return the correct element size");
+  // try to reset the state
+  _free_list = NULL;
+  delete dummy;
+}
+
+void HeapRegionRemSet::test_prt() {
+  PerRegionTable::test_fl_mem_size();
+}
+
 void HeapRegionRemSet::test() {
   os::sleep(Thread::current(), (jlong)5000, false);
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -338,6 +338,7 @@
 
   // Run unit tests.
 #ifndef PRODUCT
+  static void test_prt();
   static void test();
 #endif
 };
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -54,18 +54,18 @@
   const size_t raw_bytes = words * sizeof(idx_t);
   const size_t page_sz = os::page_size_for_region(raw_bytes, raw_bytes, 10);
   const size_t granularity = os::vm_allocation_granularity();
-  const size_t bytes = align_size_up(raw_bytes, MAX2(page_sz, granularity));
+  _reserved_byte_size = align_size_up(raw_bytes, MAX2(page_sz, granularity));
 
   const size_t rs_align = page_sz == (size_t) os::vm_page_size() ? 0 :
     MAX2(page_sz, granularity);
-  ReservedSpace rs(bytes, rs_align, rs_align > 0);
+  ReservedSpace rs(_reserved_byte_size, rs_align, rs_align > 0);
   os::trace_page_sizes("par bitmap", raw_bytes, raw_bytes, page_sz,
                        rs.base(), rs.size());
 
   MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
 
   _virtual_space = new PSVirtualSpace(rs, page_sz);
-  if (_virtual_space != NULL && _virtual_space->expand_by(bytes)) {
+  if (_virtual_space != NULL && _virtual_space->expand_by(_reserved_byte_size)) {
     _region_start = covered_region.start();
     _region_size = covered_region.word_size();
     idx_t* map = (idx_t*)_virtual_space->reserved_low_addr();
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -131,6 +131,8 @@
   inline size_t    region_size() const;
   inline size_t    size() const;
 
+  size_t reserved_byte_size() const { return _reserved_byte_size; }
+
   // Convert a heap address to/from a bit index.
   inline idx_t     addr_to_bit(HeapWord* addr) const;
   inline HeapWord* bit_to_addr(idx_t bit) const;
@@ -176,10 +178,11 @@
   BitMap          _beg_bits;
   BitMap          _end_bits;
   PSVirtualSpace* _virtual_space;
+  size_t          _reserved_byte_size;
 };
 
 inline ParMarkBitMap::ParMarkBitMap():
-  _beg_bits(), _end_bits(), _region_start(NULL), _region_size(0), _virtual_space(NULL)
+  _beg_bits(), _end_bits(), _region_start(NULL), _region_size(0), _virtual_space(NULL), _reserved_byte_size(0)
 { }
 
 inline void ParMarkBitMap::clear_range(idx_t beg, idx_t end)
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -580,7 +580,6 @@
 // This should be moved to the shared markSweep code!
 class PSAlwaysTrueClosure: public BoolObjectClosure {
 public:
-  void do_object(oop p) { ShouldNotReachHere(); }
   bool do_object_b(oop p) { return true; }
 };
 static PSAlwaysTrueClosure always_true;
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -356,6 +356,7 @@
   _region_start = 0;
 
   _region_vspace = 0;
+  _reserved_byte_size = 0;
   _region_data = 0;
   _region_count = 0;
 }
@@ -382,11 +383,11 @@
   const size_t raw_bytes = count * element_size;
   const size_t page_sz = os::page_size_for_region(raw_bytes, raw_bytes, 10);
   const size_t granularity = os::vm_allocation_granularity();
-  const size_t bytes = align_size_up(raw_bytes, MAX2(page_sz, granularity));
+  _reserved_byte_size = align_size_up(raw_bytes, MAX2(page_sz, granularity));
 
   const size_t rs_align = page_sz == (size_t) os::vm_page_size() ? 0 :
     MAX2(page_sz, granularity);
-  ReservedSpace rs(bytes, rs_align, rs_align > 0);
+  ReservedSpace rs(_reserved_byte_size, rs_align, rs_align > 0);
   os::trace_page_sizes("par compact", raw_bytes, raw_bytes, page_sz, rs.base(),
                        rs.size());
 
@@ -394,7 +395,7 @@
 
   PSVirtualSpace* vspace = new PSVirtualSpace(rs, page_sz);
   if (vspace != 0) {
-    if (vspace->expand_by(bytes)) {
+    if (vspace->expand_by(_reserved_byte_size)) {
       return vspace;
     }
     delete vspace;
@@ -781,7 +782,6 @@
 
 PSParallelCompact::IsAliveClosure PSParallelCompact::_is_alive_closure;
 
-void PSParallelCompact::IsAliveClosure::do_object(oop p)   { ShouldNotReachHere(); }
 bool PSParallelCompact::IsAliveClosure::do_object_b(oop p) { return mark_bitmap()->is_marked(p); }
 
 void PSParallelCompact::KeepAliveClosure::do_oop(oop* p)       { PSParallelCompact::KeepAliveClosure::do_oop_work(p); }
@@ -841,14 +841,18 @@
   initialize_dead_wood_limiter();
 
   if (!_mark_bitmap.initialize(mr)) {
-    vm_shutdown_during_initialization("Unable to allocate bit map for "
-      "parallel garbage collection for the requested heap size.");
+    vm_shutdown_during_initialization(
+      err_msg("Unable to allocate " SIZE_FORMAT "KB bitmaps for parallel "
+      "garbage collection for the requested " SIZE_FORMAT "KB heap.",
+      _mark_bitmap.reserved_byte_size()/K, mr.byte_size()/K));
     return false;
   }
 
   if (!_summary_data.initialize(mr)) {
-    vm_shutdown_during_initialization("Unable to allocate tables for "
-      "parallel garbage collection for the requested heap size.");
+    vm_shutdown_during_initialization(
+      err_msg("Unable to allocate " SIZE_FORMAT "KB card tables for parallel "
+      "garbage collection for the requested " SIZE_FORMAT "KB heap.",
+      _summary_data.reserved_byte_size()/K, mr.byte_size()/K));
     return false;
   }
 
@@ -2413,7 +2417,6 @@
 // This should be moved to the shared markSweep code!
 class PSAlwaysTrueClosure: public BoolObjectClosure {
 public:
-  void do_object(oop p) { ShouldNotReachHere(); }
   bool do_object_b(oop p) { return true; }
 };
 static PSAlwaysTrueClosure always_true;
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -347,6 +347,7 @@
   bool initialize(MemRegion covered_region);
 
   size_t region_count() const { return _region_count; }
+  size_t reserved_byte_size() const { return _reserved_byte_size; }
 
   // Convert region indices to/from RegionData pointers.
   inline RegionData* region(size_t region_idx) const;
@@ -420,6 +421,7 @@
 #endif  // #ifdef ASSERT
 
   PSVirtualSpace* _region_vspace;
+  size_t          _reserved_byte_size;
   RegionData*     _region_data;
   size_t          _region_count;
 };
@@ -784,7 +786,6 @@
   //
   class IsAliveClosure: public BoolObjectClosure {
    public:
-    virtual void do_object(oop p);
     virtual bool do_object_b(oop p);
   };
 
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -70,9 +70,6 @@
 // Define before use
 class PSIsAliveClosure: public BoolObjectClosure {
 public:
-  void do_object(oop p) {
-    assert(false, "Do not call.");
-  }
   bool do_object_b(oop p) {
     return (!PSScavenge::is_obj_in_young((HeapWord*) p)) || p->is_forwarded();
   }
--- a/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -166,7 +166,6 @@
 
 MarkSweep::IsAliveClosure   MarkSweep::is_alive;
 
-void MarkSweep::IsAliveClosure::do_object(oop p)   { ShouldNotReachHere(); }
 bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); }
 
 MarkSweep::KeepAliveClosure MarkSweep::keep_alive;
--- a/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -88,7 +88,6 @@
   // Used for java/lang/ref handling
   class IsAliveClosure: public BoolObjectClosure {
    public:
-    virtual void do_object(oop p);
     virtual bool do_object_b(oop p);
   };
 
--- a/hotspot/src/share/vm/memory/defNewGeneration.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -50,9 +50,6 @@
 DefNewGeneration::IsAliveClosure::IsAliveClosure(Generation* g) : _g(g) {
   assert(g->level() == 0, "Optimized for youngest gen.");
 }
-void DefNewGeneration::IsAliveClosure::do_object(oop p) {
-  assert(false, "Do not call.");
-}
 bool DefNewGeneration::IsAliveClosure::do_object_b(oop p) {
   return (HeapWord*)p >= _g->reserved().end() || p->is_forwarded();
 }
--- a/hotspot/src/share/vm/memory/defNewGeneration.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/memory/defNewGeneration.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -150,7 +150,6 @@
     Generation* _g;
   public:
     IsAliveClosure(Generation* g);
-    void do_object(oop p);
     bool do_object_b(oop p);
   };
 
--- a/hotspot/src/share/vm/memory/freeList.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/memory/freeList.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -55,17 +55,6 @@
 }
 
 template <class Chunk>
-FreeList<Chunk>::FreeList(Chunk* fc) :
-  _head(fc), _tail(fc)
-#ifdef ASSERT
-  , _protecting_lock(NULL)
-#endif
-{
-  _size         = fc->size();
-  _count        = 1;
-}
-
-template <class Chunk>
 void FreeList<Chunk>::link_head(Chunk* v) {
   assert_proper_lock_protection();
   set_head(v);
--- a/hotspot/src/share/vm/memory/freeList.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/memory/freeList.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -80,8 +80,6 @@
   // Constructor
   // Construct a list without any entries.
   FreeList();
-  // Construct a list with "fc" as the first (and lone) entry in the list.
-  FreeList(Chunk_t* fc);
 
   // Do initialization
   void initialize();
@@ -177,9 +175,6 @@
   // found.  Return NULL if "fc" is not found.
   bool verify_chunk_in_free_list(Chunk_t* fc) const;
 
-  // Stats verification
-//  void verify_stats() const { ShouldNotReachHere(); };
-
   // Printing support
   static void print_labels_on(outputStream* st, const char* c);
   void print_on(outputStream* st, const char* c = NULL) const;
--- a/hotspot/src/share/vm/memory/iterator.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/memory/iterator.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -158,7 +158,7 @@
 };
 
 
-class BoolObjectClosure : public ObjectClosure {
+class BoolObjectClosure : public Closure {
  public:
   virtual bool do_object_b(oop obj) = 0;
 };
--- a/hotspot/src/share/vm/memory/metaspace.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/memory/metaspace.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -562,6 +562,9 @@
   // protects allocations and contains.
   Mutex* const _lock;
 
+  // Type of metadata allocated.
+  Metaspace::MetadataType _mdtype;
+
   // Chunk related size
   size_t _medium_chunk_bunch;
 
@@ -606,6 +609,7 @@
     return (BlockFreelist*) &_block_freelists;
   }
 
+  Metaspace::MetadataType mdtype() { return _mdtype; }
   VirtualSpaceList* vs_list() const    { return _vs_list; }
 
   Metachunk* current_chunk() const { return _current_chunk; }
@@ -626,7 +630,8 @@
   void initialize();
 
  public:
-  SpaceManager(Mutex* lock,
+  SpaceManager(Metaspace::MetadataType mdtype,
+               Mutex* lock,
                VirtualSpaceList* vs_list);
   ~SpaceManager();
 
@@ -2032,9 +2037,11 @@
   }
 }
 
-SpaceManager::SpaceManager(Mutex* lock,
+SpaceManager::SpaceManager(Metaspace::MetadataType mdtype,
+                           Mutex* lock,
                            VirtualSpaceList* vs_list) :
   _vs_list(vs_list),
+  _mdtype(mdtype),
   _allocated_blocks_words(0),
   _allocated_chunks_words(0),
   _allocated_chunks_count(0),
@@ -2050,27 +2057,27 @@
   _allocated_chunks_words = _allocated_chunks_words + words;
   _allocated_chunks_count++;
   // Global total of capacity in allocated Metachunks
-  MetaspaceAux::inc_capacity(words);
+  MetaspaceAux::inc_capacity(mdtype(), words);
   // Global total of allocated Metablocks.
   // used_words_slow() includes the overhead in each
   // Metachunk so include it in the used when the
   // Metachunk is first added (so only added once per
   // Metachunk).
-  MetaspaceAux::inc_used(Metachunk::overhead());
+  MetaspaceAux::inc_used(mdtype(), Metachunk::overhead());
 }
 
 void SpaceManager::inc_used_metrics(size_t words) {
   // Add to the per SpaceManager total
   Atomic::add_ptr(words, &_allocated_blocks_words);
   // Add to the global total
-  MetaspaceAux::inc_used(words);
+  MetaspaceAux::inc_used(mdtype(), words);
 }
 
 void SpaceManager::dec_total_from_size_metrics() {
-  MetaspaceAux::dec_capacity(allocated_chunks_words());
-  MetaspaceAux::dec_used(allocated_blocks_words());
+  MetaspaceAux::dec_capacity(mdtype(), allocated_chunks_words());
+  MetaspaceAux::dec_used(mdtype(), allocated_blocks_words());
   // Also deduct the overhead per Metachunk
-  MetaspaceAux::dec_used(allocated_chunks_count() * Metachunk::overhead());
+  MetaspaceAux::dec_used(mdtype(), allocated_chunks_count() * Metachunk::overhead());
 }
 
 void SpaceManager::initialize() {
@@ -2470,8 +2477,8 @@
 // MetaspaceAux
 
 
-size_t MetaspaceAux::_allocated_capacity_words = 0;
-size_t MetaspaceAux::_allocated_used_words = 0;
+size_t MetaspaceAux::_allocated_capacity_words[] = {0, 0};
+size_t MetaspaceAux::_allocated_used_words[] = {0, 0};
 
 size_t MetaspaceAux::free_bytes() {
   size_t result = 0;
@@ -2484,40 +2491,40 @@
   return result;
 }
 
-void MetaspaceAux::dec_capacity(size_t words) {
+void MetaspaceAux::dec_capacity(Metaspace::MetadataType mdtype, size_t words) {
   assert_lock_strong(SpaceManager::expand_lock());
-  assert(words <= _allocated_capacity_words,
+  assert(words <= allocated_capacity_words(mdtype),
     err_msg("About to decrement below 0: words " SIZE_FORMAT
-            " is greater than _allocated_capacity_words " SIZE_FORMAT,
-            words, _allocated_capacity_words));
-  _allocated_capacity_words = _allocated_capacity_words - words;
+            " is greater than _allocated_capacity_words[%u] " SIZE_FORMAT,
+            words, mdtype, allocated_capacity_words(mdtype)));
+  _allocated_capacity_words[mdtype] -= words;
 }
 
-void MetaspaceAux::inc_capacity(size_t words) {
+void MetaspaceAux::inc_capacity(Metaspace::MetadataType mdtype, size_t words) {
   assert_lock_strong(SpaceManager::expand_lock());
   // Needs to be atomic
-  _allocated_capacity_words = _allocated_capacity_words + words;
+  _allocated_capacity_words[mdtype] += words;
 }
 
-void MetaspaceAux::dec_used(size_t words) {
-  assert(words <= _allocated_used_words,
+void MetaspaceAux::dec_used(Metaspace::MetadataType mdtype, size_t words) {
+  assert(words <= allocated_used_words(mdtype),
     err_msg("About to decrement below 0: words " SIZE_FORMAT
-            " is greater than _allocated_used_words " SIZE_FORMAT,
-            words, _allocated_used_words));
+            " is greater than _allocated_used_words[%u] " SIZE_FORMAT,
+            words, mdtype, allocated_used_words(mdtype)));
   // For CMS deallocation of the Metaspaces occurs during the
   // sweep which is a concurrent phase.  Protection by the expand_lock()
   // is not enough since allocation is on a per Metaspace basis
   // and protected by the Metaspace lock.
   jlong minus_words = (jlong) - (jlong) words;
-  Atomic::add_ptr(minus_words, &_allocated_used_words);
+  Atomic::add_ptr(minus_words, &_allocated_used_words[mdtype]);
 }
 
-void MetaspaceAux::inc_used(size_t words) {
+void MetaspaceAux::inc_used(Metaspace::MetadataType mdtype, size_t words) {
   // _allocated_used_words tracks allocations for
   // each piece of metadata.  Those allocations are
   // generally done concurrently by different application
   // threads so must be done atomically.
-  Atomic::add_ptr(words, &_allocated_used_words);
+  Atomic::add_ptr(words, &_allocated_used_words[mdtype]);
 }
 
 size_t MetaspaceAux::used_bytes_slow(Metaspace::MetadataType mdtype) {
@@ -2619,21 +2626,19 @@
                 SIZE_FORMAT "K, used " SIZE_FORMAT "K,"
                 " reserved " SIZE_FORMAT "K",
                 allocated_capacity_bytes()/K, allocated_used_bytes()/K, reserved_in_bytes()/K);
-#if 0
-// The calls to capacity_bytes_slow() and used_bytes_slow() cause
-// lock ordering assertion failures with some collectors.  Do
-// not include this code until the lock ordering is fixed.
-  if (PrintGCDetails && Verbose) {
-    out->print_cr("  data space     "
-                  SIZE_FORMAT "K, used " SIZE_FORMAT "K,"
-                  " reserved " SIZE_FORMAT "K",
-                  capacity_bytes_slow(nct)/K, used_bytes_slow(nct)/K, reserved_in_bytes(nct)/K);
-    out->print_cr("  class space    "
-                  SIZE_FORMAT "K, used " SIZE_FORMAT "K,"
-                  " reserved " SIZE_FORMAT "K",
-                  capacity_bytes_slow(ct)/K, used_bytes_slow(ct)/K, reserved_in_bytes(ct)/K);
-  }
-#endif
+
+  out->print_cr("  data space     "
+                SIZE_FORMAT "K, used " SIZE_FORMAT "K,"
+                " reserved " SIZE_FORMAT "K",
+                allocated_capacity_bytes(nct)/K,
+                allocated_used_bytes(nct)/K,
+                reserved_in_bytes(nct)/K);
+  out->print_cr("  class space    "
+                SIZE_FORMAT "K, used " SIZE_FORMAT "K,"
+                " reserved " SIZE_FORMAT "K",
+                allocated_capacity_bytes(ct)/K,
+                allocated_used_bytes(ct)/K,
+                reserved_in_bytes(ct)/K);
 }
 
 // Print information for class space and data space separately.
@@ -2717,24 +2722,42 @@
 void MetaspaceAux::verify_capacity() {
 #ifdef ASSERT
   size_t running_sum_capacity_bytes = allocated_capacity_bytes();
-  // For purposes of the running sum of used, verify against capacity
+  // For purposes of the running sum of capacity, verify against capacity
   size_t capacity_in_use_bytes = capacity_bytes_slow();
   assert(running_sum_capacity_bytes == capacity_in_use_bytes,
     err_msg("allocated_capacity_words() * BytesPerWord " SIZE_FORMAT
             " capacity_bytes_slow()" SIZE_FORMAT,
             running_sum_capacity_bytes, capacity_in_use_bytes));
+  for (Metaspace::MetadataType i = Metaspace::ClassType;
+       i < Metaspace:: MetadataTypeCount;
+       i = (Metaspace::MetadataType)(i + 1)) {
+    size_t capacity_in_use_bytes = capacity_bytes_slow(i);
+    assert(allocated_capacity_bytes(i) == capacity_in_use_bytes,
+      err_msg("allocated_capacity_bytes(%u) " SIZE_FORMAT
+              " capacity_bytes_slow(%u)" SIZE_FORMAT,
+              i, allocated_capacity_bytes(i), i, capacity_in_use_bytes));
+  }
 #endif
 }
 
 void MetaspaceAux::verify_used() {
 #ifdef ASSERT
   size_t running_sum_used_bytes = allocated_used_bytes();
-  // For purposes of the running sum of used, verify against capacity
+  // For purposes of the running sum of used, verify against used
   size_t used_in_use_bytes = used_bytes_slow();
   assert(allocated_used_bytes() == used_in_use_bytes,
     err_msg("allocated_used_bytes() " SIZE_FORMAT
-            " used_bytes_slow()()" SIZE_FORMAT,
+            " used_bytes_slow()" SIZE_FORMAT,
             allocated_used_bytes(), used_in_use_bytes));
+  for (Metaspace::MetadataType i = Metaspace::ClassType;
+       i < Metaspace:: MetadataTypeCount;
+       i = (Metaspace::MetadataType)(i + 1)) {
+    size_t used_in_use_bytes = used_bytes_slow(i);
+    assert(allocated_used_bytes(i) == used_in_use_bytes,
+      err_msg("allocated_used_bytes(%u) " SIZE_FORMAT
+              " used_bytes_slow(%u)" SIZE_FORMAT,
+              i, allocated_used_bytes(i), i, used_in_use_bytes));
+  }
 #endif
 }
 
@@ -2835,7 +2858,7 @@
   assert(space_list() != NULL,
     "Metadata VirtualSpaceList has not been initialized");
 
-  _vsm = new SpaceManager(lock, space_list());
+  _vsm = new SpaceManager(Metaspace::NonClassType, lock, space_list());
   if (_vsm == NULL) {
     return;
   }
@@ -2849,7 +2872,7 @@
     "Class VirtualSpaceList has not been initialized");
 
   // Allocate SpaceManager for classes.
-  _class_vsm = new SpaceManager(lock, class_space_list());
+  _class_vsm = new SpaceManager(Metaspace::ClassType, lock, class_space_list());
   if (_class_vsm == NULL) {
     return;
   }
--- a/hotspot/src/share/vm/memory/metaspace.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/memory/metaspace.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -86,7 +86,10 @@
   friend class MetaspaceAux;
 
  public:
-  enum MetadataType {ClassType, NonClassType};
+  enum MetadataType {ClassType = 0,
+                     NonClassType = ClassType + 1,
+                     MetadataTypeCount = ClassType + 2
+  };
   enum MetaspaceType {
     StandardMetaspaceType,
     BootMetaspaceType,
@@ -184,20 +187,22 @@
  public:
   // Running sum of space in all Metachunks that has been
   // allocated to a Metaspace.  This is used instead of
-  // iterating over all the classloaders
-  static size_t _allocated_capacity_words;
+  // iterating over all the classloaders. One for each
+  // type of Metadata
+  static size_t _allocated_capacity_words[Metaspace:: MetadataTypeCount];
   // Running sum of space in all Metachunks that have
-  // are being used for metadata.
-  static size_t _allocated_used_words;
+  // are being used for metadata. One for each
+  // type of Metadata.
+  static size_t _allocated_used_words[Metaspace:: MetadataTypeCount];
 
  public:
   // Decrement and increment _allocated_capacity_words
-  static void dec_capacity(size_t words);
-  static void inc_capacity(size_t words);
+  static void dec_capacity(Metaspace::MetadataType type, size_t words);
+  static void inc_capacity(Metaspace::MetadataType type, size_t words);
 
   // Decrement and increment _allocated_used_words
-  static void dec_used(size_t words);
-  static void inc_used(size_t words);
+  static void dec_used(Metaspace::MetadataType type, size_t words);
+  static void inc_used(Metaspace::MetadataType type, size_t words);
 
   // Total of space allocated to metadata in all Metaspaces.
   // This sums the space used in each Metachunk by
@@ -211,18 +216,32 @@
   static size_t free_chunks_total();
   static size_t free_chunks_total_in_bytes();
 
+  static size_t allocated_capacity_words(Metaspace::MetadataType mdtype) {
+    return _allocated_capacity_words[mdtype];
+  }
   static size_t allocated_capacity_words() {
-    return _allocated_capacity_words;
+    return _allocated_capacity_words[Metaspace::ClassType] +
+           _allocated_capacity_words[Metaspace::NonClassType];
+  }
+  static size_t allocated_capacity_bytes(Metaspace::MetadataType mdtype) {
+    return allocated_capacity_words(mdtype) * BytesPerWord;
   }
   static size_t allocated_capacity_bytes() {
-    return _allocated_capacity_words * BytesPerWord;
+    return allocated_capacity_words() * BytesPerWord;
   }
 
+  static size_t allocated_used_words(Metaspace::MetadataType mdtype) {
+    return _allocated_used_words[mdtype];
+  }
   static size_t allocated_used_words() {
-    return _allocated_used_words;
+    return _allocated_used_words[Metaspace::ClassType] +
+           _allocated_used_words[Metaspace::NonClassType];
+  }
+  static size_t allocated_used_bytes(Metaspace::MetadataType mdtype) {
+    return allocated_used_words(mdtype) * BytesPerWord;
   }
   static size_t allocated_used_bytes() {
-    return _allocated_used_words * BytesPerWord;
+    return allocated_used_words() * BytesPerWord;
   }
 
   static size_t free_bytes();
--- a/hotspot/src/share/vm/memory/referenceProcessor.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/memory/referenceProcessor.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -252,7 +252,6 @@
   class AlwaysAliveClosure: public BoolObjectClosure {
   public:
     virtual bool do_object_b(oop obj) { return true; }
-    virtual void do_object(oop obj) { assert(false, "Don't call"); }
   };
 
   class CountHandleClosure: public OopClosure {
--- a/hotspot/src/share/vm/memory/sharedHeap.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/memory/sharedHeap.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -212,7 +212,6 @@
 
 class AlwaysTrueClosure: public BoolObjectClosure {
 public:
-  void do_object(oop p) { ShouldNotReachHere(); }
   bool do_object_b(oop p) { return true; }
 };
 static AlwaysTrueClosure always_true;
--- a/hotspot/src/share/vm/opto/loopnode.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/opto/loopnode.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -965,7 +965,7 @@
   // Has use internal to the vector set (ie. not in a phi at the loop head)
   bool has_use_internal_to_set( Node* n, VectorSet& vset, IdealLoopTree *loop );
   // clone "n" for uses that are outside of loop
-  void clone_for_use_outside_loop( IdealLoopTree *loop, Node* n, Node_List& worklist );
+  int  clone_for_use_outside_loop( IdealLoopTree *loop, Node* n, Node_List& worklist );
   // clone "n" for special uses that are in the not_peeled region
   void clone_for_special_use_inside_loop( IdealLoopTree *loop, Node* n,
                                           VectorSet& not_peel, Node_List& sink_list, Node_List& worklist );
--- a/hotspot/src/share/vm/opto/loopopts.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/opto/loopopts.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -1939,8 +1939,8 @@
 
 //------------------------------ clone_for_use_outside_loop -------------------------------------
 // clone "n" for uses that are outside of loop
-void PhaseIdealLoop::clone_for_use_outside_loop( IdealLoopTree *loop, Node* n, Node_List& worklist ) {
-
+int PhaseIdealLoop::clone_for_use_outside_loop( IdealLoopTree *loop, Node* n, Node_List& worklist ) {
+  int cloned = 0;
   assert(worklist.size() == 0, "should be empty");
   for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
     Node* use = n->fast_out(j);
@@ -1960,6 +1960,7 @@
     // clone "n" and insert it between the inputs of "n" and the use outside the loop
     Node* n_clone = n->clone();
     _igvn.replace_input_of(use, j, n_clone);
+    cloned++;
     Node* use_c;
     if (!use->is_Phi()) {
       use_c = has_ctrl(use) ? get_ctrl(use) : use->in(0);
@@ -1977,6 +1978,7 @@
     }
 #endif
   }
+  return cloned;
 }
 
 
@@ -2495,6 +2497,7 @@
 
   // Evacuate nodes in peel region into the not_peeled region if possible
   uint new_phi_cnt = 0;
+  uint cloned_for_outside_use = 0;
   for (i = 0; i < peel_list.size();) {
     Node* n = peel_list.at(i);
 #if !defined(PRODUCT)
@@ -2513,8 +2516,7 @@
           // if not pinned and not a load (which maybe anti-dependent on a store)
           // and not a CMove (Matcher expects only bool->cmove).
           if ( n->in(0) == NULL && !n->is_Load() && !n->is_CMove() ) {
-            clone_for_use_outside_loop( loop, n, worklist );
-
+            cloned_for_outside_use += clone_for_use_outside_loop( loop, n, worklist );
             sink_list.push(n);
             peel     >>= n->_idx; // delete n from peel set.
             not_peel <<= n->_idx; // add n to not_peel set.
@@ -2551,6 +2553,12 @@
     // Inhibit more partial peeling on this loop
     assert(!head->is_partial_peel_loop(), "not partial peeled");
     head->mark_partial_peel_failed();
+    if (cloned_for_outside_use > 0) {
+      // Terminate this round of loop opts because
+      // the graph outside this loop was changed.
+      C->set_major_progress();
+      return true;
+    }
     return false;
   }
 
--- a/hotspot/src/share/vm/prims/jni.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/prims/jni.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -5015,6 +5015,9 @@
 #ifndef PRODUCT
 
 #include "gc_interface/collectedHeap.hpp"
+#if INCLUDE_ALL_GCS
+#include "gc_implementation/g1/heapRegionRemSet.hpp"
+#endif
 #include "utilities/quickSort.hpp"
 #if INCLUDE_VM_STRUCTS
 #include "runtime/vmStructs.hpp"
@@ -5035,6 +5038,9 @@
 #if INCLUDE_VM_STRUCTS
     run_unit_test(VMStructs::test());
 #endif
+#if INCLUDE_ALL_GCS
+    run_unit_test(HeapRegionRemSet::test_prt());
+#endif
     tty->print_cr("All internal VM tests passed");
   }
 }
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -1624,15 +1624,19 @@
     }
   }
 
+  assert(sig_type != '[', "array should have sig_type == 'L'");
+  bool handle_created = false;
+
   // convert oop to JNI handle.
-  if (sig_type == 'L' || sig_type == '[') {
+  if (sig_type == 'L') {
+    handle_created = true;
     value->l = (jobject)JNIHandles::make_local(thread, (oop)value->l);
   }
 
   post_field_modification(thread, method, location, field_klass, object, field, sig_type, value);
 
   // Destroy the JNI handle allocated above.
-  if (sig_type == 'L') {
+  if (handle_created) {
     JNIHandles::destroy_local(value->l);
   }
 }
--- a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -68,7 +68,7 @@
   }
 #endif
 
-
+  set_increase_threshold_at_ratio();
   set_start_time(os::javaTimeMillis());
 }
 
@@ -205,6 +205,17 @@
   double queue_size = CompileBroker::queue_size(level);
   int comp_count = compiler_count(level);
   double k = queue_size / (feedback_k * comp_count) + 1;
+
+  // Increase C1 compile threshold when the code cache is filled more
+  // than specified by IncreaseFirstTierCompileThresholdAt percentage.
+  // The main intention is to keep enough free space for C2 compiled code
+  // to achieve peak performance if the code cache is under stress.
+  if ((TieredStopAtLevel == CompLevel_full_optimization) && (level != CompLevel_full_optimization))  {
+    double current_reverse_free_ratio = CodeCache::reverse_free_ratio();
+    if (current_reverse_free_ratio > _increase_threshold_at_ratio) {
+      k *= exp(current_reverse_free_ratio - _increase_threshold_at_ratio);
+    }
+  }
   return k;
 }
 
--- a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -201,9 +201,12 @@
   // Is method profiled enough?
   bool is_method_profiled(Method* method);
 
+  double _increase_threshold_at_ratio;
+
 protected:
   void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level);
 
+  void set_increase_threshold_at_ratio() { _increase_threshold_at_ratio = 100 / (100 - (double)IncreaseFirstTierCompileThresholdAt); }
   void set_start_time(jlong t) { _start_time = t;    }
   jlong start_time() const     { return _start_time; }
 
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -2629,6 +2629,16 @@
         return JNI_EINVAL;
       }
       FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize);
+      //-XX:IncreaseFirstTierCompileThresholdAt=
+      } else if (match_option(option, "-XX:IncreaseFirstTierCompileThresholdAt=", &tail)) {
+        uintx uint_IncreaseFirstTierCompileThresholdAt = 0;
+        if (!parse_uintx(tail, &uint_IncreaseFirstTierCompileThresholdAt, 0) || uint_IncreaseFirstTierCompileThresholdAt > 99) {
+          jio_fprintf(defaultStream::error_stream(),
+                      "Invalid value for IncreaseFirstTierCompileThresholdAt: %s. Should be between 0 and 99.\n",
+                      option->optionString);
+          return JNI_EINVAL;
+        }
+        FLAG_SET_CMDLINE(uintx, IncreaseFirstTierCompileThresholdAt, (uintx)uint_IncreaseFirstTierCompileThresholdAt);
     // -green
     } else if (match_option(option, "-green", &tail)) {
       jio_fprintf(defaultStream::error_stream(),
--- a/hotspot/src/share/vm/runtime/globals.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -3436,6 +3436,10 @@
           "Start profiling in interpreter if the counters exceed tier 3"    \
           "thresholds by the specified percentage")                         \
                                                                             \
+  product(uintx, IncreaseFirstTierCompileThresholdAt, 50,                   \
+          "Increase the compile threshold for C1 compilation if the code"   \
+          "cache is filled by the specified percentage.")                   \
+                                                                            \
   product(intx, TieredRateUpdateMinTime, 1,                                 \
           "Minimum rate sampling interval (in milliseconds)")               \
                                                                             \
--- a/hotspot/src/share/vm/runtime/jniHandles.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/runtime/jniHandles.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -188,7 +188,6 @@
 class AlwaysAliveClosure: public BoolObjectClosure {
 public:
   bool do_object_b(oop obj) { return true; }
-  void do_object(oop obj) { assert(false, "Don't call"); }
 };
 
 class CountHandleClosure: public OopClosure {
--- a/hotspot/src/share/vm/utilities/debug.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/utilities/debug.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -665,152 +665,4 @@
   tty->print_cr("  ndebug()      - undo debug");
 }
 
-#if 0
-
-// BobV's command parser for debugging on windows when nothing else works.
-
-enum CommandID {
-  CMDID_HELP,
-  CMDID_QUIT,
-  CMDID_HSFIND,
-  CMDID_PSS,
-  CMDID_PS,
-  CMDID_PSF,
-  CMDID_FINDM,
-  CMDID_FINDNM,
-  CMDID_PP,
-  CMDID_BPT,
-  CMDID_EXIT,
-  CMDID_VERIFY,
-  CMDID_THREADS,
-  CMDID_ILLEGAL = 99
-};
-
-struct CommandParser {
-   char *name;
-   CommandID code;
-   char *description;
-};
-
-struct CommandParser CommandList[] = {
-  (char *)"help", CMDID_HELP, "  Dump this list",
-  (char *)"quit", CMDID_QUIT, "  Return from this routine",
-  (char *)"hsfind", CMDID_HSFIND, "Perform an hsfind on an address",
-  (char *)"ps", CMDID_PS, "    Print Current Thread Stack Trace",
-  (char *)"pss", CMDID_PSS, "   Print All Thread Stack Trace",
-  (char *)"psf", CMDID_PSF, "   Print All Stack Frames",
-  (char *)"findm", CMDID_FINDM, " Find a Method* from a PC",
-  (char *)"findnm", CMDID_FINDNM, "Find an nmethod from a PC",
-  (char *)"pp", CMDID_PP, "    Find out something about a pointer",
-  (char *)"break", CMDID_BPT, " Execute a breakpoint",
-  (char *)"exitvm", CMDID_EXIT, "Exit the VM",
-  (char *)"verify", CMDID_VERIFY, "Perform a Heap Verify",
-  (char *)"thread", CMDID_THREADS, "Dump Info on all Threads",
-  (char *)0, CMDID_ILLEGAL
-};
-
-
-// get_debug_command()
-//
-// Read a command from standard input.
-// This is useful when you have a debugger
-// which doesn't support calling into functions.
-//
-void get_debug_command()
-{
-  ssize_t count;
-  int i,j;
-  bool gotcommand;
-  intptr_t addr;
-  char buffer[256];
-  nmethod *nm;
-  Method* m;
-
-  tty->print_cr("You have entered the diagnostic command interpreter");
-  tty->print("The supported commands are:\n");
-  for ( i=0; ; i++ ) {
-    if ( CommandList[i].code == CMDID_ILLEGAL )
-      break;
-    tty->print_cr("  %s \n", CommandList[i].name );
-  }
-
-  while ( 1 ) {
-    gotcommand = false;
-    tty->print("Please enter a command: ");
-    count = scanf("%s", buffer) ;
-    if ( count >=0 ) {
-      for ( i=0; ; i++ ) {
-        if ( CommandList[i].code == CMDID_ILLEGAL ) {
-          if (!gotcommand) tty->print("Invalid command, please try again\n");
-          break;
-        }
-        if ( strcmp(buffer, CommandList[i].name) == 0 ) {
-          gotcommand = true;
-          switch ( CommandList[i].code ) {
-              case CMDID_PS:
-                ps();
-                break;
-              case CMDID_PSS:
-                pss();
-                break;
-              case CMDID_PSF:
-                psf();
-                break;
-              case CMDID_FINDM:
-                tty->print("Please enter the hex addr to pass to findm: ");
-                scanf("%I64X", &addr);
-                m = (Method*)findm(addr);
-                tty->print("findm(0x%I64X) returned 0x%I64X\n", addr, m);
-                break;
-              case CMDID_FINDNM:
-                tty->print("Please enter the hex addr to pass to findnm: ");
-                scanf("%I64X", &addr);
-                nm = (nmethod*)findnm(addr);
-                tty->print("findnm(0x%I64X) returned 0x%I64X\n", addr, nm);
-                break;
-              case CMDID_PP:
-                tty->print("Please enter the hex addr to pass to pp: ");
-                scanf("%I64X", &addr);
-                pp((void*)addr);
-                break;
-              case CMDID_EXIT:
-                exit(0);
-              case CMDID_HELP:
-                tty->print("Here are the supported commands: ");
-                for ( j=0; ; j++ ) {
-                  if ( CommandList[j].code == CMDID_ILLEGAL )
-                    break;
-                  tty->print_cr("  %s --  %s\n", CommandList[j].name,
-                                                 CommandList[j].description );
-                }
-                break;
-              case CMDID_QUIT:
-                return;
-                break;
-              case CMDID_BPT:
-                BREAKPOINT;
-                break;
-              case CMDID_VERIFY:
-                verify();;
-                break;
-              case CMDID_THREADS:
-                threads();;
-                break;
-              case CMDID_HSFIND:
-                tty->print("Please enter the hex addr to pass to hsfind: ");
-                scanf("%I64X", &addr);
-                tty->print("Calling hsfind(0x%I64X)\n", addr);
-                hsfind(addr);
-                break;
-              default:
-              case CMDID_ILLEGAL:
-                break;
-          }
-        }
-      }
-    }
-  }
-}
-#endif
-
 #endif // !PRODUCT
--- a/hotspot/src/share/vm/utilities/hashtable.cpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/utilities/hashtable.cpp	Wed Jul 05 18:57:02 2017 +0200
@@ -33,6 +33,7 @@
 #include "utilities/dtrace.hpp"
 #include "utilities/hashtable.hpp"
 #include "utilities/hashtable.inline.hpp"
+#include "utilities/numberSeq.hpp"
 
 
 // This is a generic hashtable, designed to be used for the symbol
@@ -237,6 +238,57 @@
   }
 }
 
+template <class T, MEMFLAGS F> int Hashtable<T, F>::literal_size(Symbol *symbol) {
+  return symbol->size() * HeapWordSize;
+}
+
+template <class T, MEMFLAGS F> int Hashtable<T, F>::literal_size(oop oop) {
+  // NOTE: this would over-count if (pre-JDK8) java_lang_Class::has_offset_field() is true,
+  // and the String.value array is shared by several Strings. However, starting from JDK8,
+  // the String.value array is not shared anymore.
+  assert(oop != NULL && oop->klass() == SystemDictionary::String_klass(), "only strings are supported");
+  return (oop->size() + java_lang_String::value(oop)->size()) * HeapWordSize;
+}
+
+// Dump footprint and bucket length statistics
+//
+// Note: if you create a new subclass of Hashtable<MyNewType, F>, you will need to
+// add a new function Hashtable<T, F>::literal_size(MyNewType lit)
+
+template <class T, MEMFLAGS F> void Hashtable<T, F>::dump_table(outputStream* st, const char *table_name) {
+  NumberSeq summary;
+  int literal_bytes = 0;
+  for (int i = 0; i < this->table_size(); ++i) {
+    int count = 0;
+    for (HashtableEntry<T, F>* e = bucket(i);
+       e != NULL; e = e->next()) {
+      count++;
+      literal_bytes += literal_size(e->literal());
+    }
+    summary.add((double)count);
+  }
+  double num_buckets = summary.num();
+  double num_entries = summary.sum();
+
+  int bucket_bytes = (int)num_buckets * sizeof(bucket(0));
+  int entry_bytes  = (int)num_entries * sizeof(HashtableEntry<T, F>);
+  int total_bytes = literal_bytes +  bucket_bytes + entry_bytes;
+
+  double bucket_avg  = (num_buckets <= 0) ? 0 : (bucket_bytes  / num_buckets);
+  double entry_avg   = (num_entries <= 0) ? 0 : (entry_bytes   / num_entries);
+  double literal_avg = (num_entries <= 0) ? 0 : (literal_bytes / num_entries);
+
+  st->print_cr("%s statistics:", table_name);
+  st->print_cr("Number of buckets       : %9d = %9d bytes, avg %7.3f", (int)num_buckets, bucket_bytes,  bucket_avg);
+  st->print_cr("Number of entries       : %9d = %9d bytes, avg %7.3f", (int)num_entries, entry_bytes,   entry_avg);
+  st->print_cr("Number of literals      : %9d = %9d bytes, avg %7.3f", (int)num_entries, literal_bytes, literal_avg);
+  st->print_cr("Total footprint         : %9s = %9d bytes", "", total_bytes);
+  st->print_cr("Average bucket size     : %9.3f", summary.avg());
+  st->print_cr("Variance of bucket size : %9.3f", summary.variance());
+  st->print_cr("Std. dev. of bucket size: %9.3f", summary.sd());
+  st->print_cr("Maximum bucket size     : %9d", (int)summary.maximum());
+}
+
 
 // Dump the hash table buckets.
 
--- a/hotspot/src/share/vm/utilities/hashtable.hpp	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/src/share/vm/utilities/hashtable.hpp	Wed Jul 05 18:57:02 2017 +0200
@@ -282,6 +282,19 @@
   static bool use_alternate_hashcode()  { return _seed != 0; }
   static jint seed()                    { return _seed; }
 
+  static int literal_size(Symbol *symbol);
+  static int literal_size(oop oop);
+
+  // The following two are currently not used, but are needed anyway because some
+  // C++ compilers (MacOS and Solaris) force the instantiation of
+  // Hashtable<ConstantPool*, mtClass>::dump_table() even though we never call this function
+  // in the VM code.
+  static int literal_size(ConstantPool *cp) {Unimplemented(); return 0;}
+  static int literal_size(Klass *k)         {Unimplemented(); return 0;}
+
+public:
+  void dump_table(outputStream* st, const char *table_name);
+
  private:
   static jint _seed;
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/8010927/Test8010927.java	Wed Jul 05 18:57:02 2017 +0200
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 8010927
+ * @summary Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
+ * @library /testlibrary/whitebox /testlibrary
+ * @build Test8010927
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. -Xmx64m -XX:NewSize=20971520 -XX:MaxNewSize=32m -XX:-UseTLAB -XX:-UseParNewGC -XX:-UseAdaptiveSizePolicy Test8010927
+ */
+
+import sun.hotspot.WhiteBox;
+import java.lang.reflect.Field;
+import sun.misc.Unsafe;
+
+/**
+ * The test creates uncommitted space between oldgen and young gen
+ * by specifying MaxNewSize bigger than NewSize.
+ * NewSize = 20971520 = (512*4K) * 10 for 4k pages
+ * Then it tries to execute arraycopy() with elements type check
+ * to the array at the end of survive space near unused space.
+ */
+
+public class Test8010927 {
+
+  private static final Unsafe U;
+
+  static {
+    try {
+      Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
+      unsafe.setAccessible(true);
+      U = (Unsafe) unsafe.get(null);
+    } catch (Exception e) {
+      throw new Error(e);
+    }
+  }
+
+  public static Object[] o;
+
+  public static final boolean debug = Boolean.getBoolean("debug");
+
+  // 2 different obect arrays but same element types
+  static Test8010927[] masterA;
+  static Object[] masterB;
+  static final Test8010927 elem = new Test8010927();
+  static final WhiteBox wb = WhiteBox.getWhiteBox();
+
+  static final int obj_header_size = U.ARRAY_OBJECT_BASE_OFFSET;
+  static final int heap_oop_size = wb.getHeapOopSize();
+  static final int card_size = 512;
+  static final int one_card = (card_size - obj_header_size)/heap_oop_size;
+
+  static final int surv_size = 2112 * 1024;
+
+  // The size is big to not fit into survive space.
+  static final Object[] cache = new Object[(surv_size / card_size)];
+
+  public static void main(String[] args) {
+    masterA = new Test8010927[one_card];
+    masterB = new Object[one_card];
+    for (int i = 0; i < one_card; ++i) {
+      masterA[i] = elem;
+      masterB[i] = elem;
+    }
+
+    // Move cache[] to the old gen.
+    long low_limit = wb.getObjectAddress(cache);
+    System.gc();
+    // Move 'cache' to oldgen.
+    long upper_limit = wb.getObjectAddress(cache);
+    if ((low_limit - upper_limit) > 0) { // substaction works with unsigned values
+      // OldGen is placed before youngger for ParallelOldGC.
+      upper_limit = low_limit + 21000000l; // +20971520
+    }
+    // Each A[one_card] size is 512 bytes,
+    // it will take about 40000 allocations to trigger GC.
+    // cache[] has 8192 elements so GC should happen
+    // each 5th iteration.
+    for(long l = 0; l < 20; l++) {
+      fill_heap();
+      if (debug) {
+        System.out.println("test oop_disjoint_arraycopy");
+      }
+      testA_arraycopy();
+      if (debug) {
+        System.out.println("test checkcast_arraycopy");
+      }
+      testB_arraycopy();
+      // Execute arraycopy to the topmost array in young gen
+      if (debug) {
+        int top_index = get_top_address(low_limit, upper_limit);
+        if (top_index >= 0) {
+          long addr = wb.getObjectAddress(cache[top_index]);
+          System.out.println("top_addr: 0x" + Long.toHexString(addr) + ", 0x" + Long.toHexString(addr + 512));
+        }
+      }
+    }
+  }
+  static void fill_heap() {
+    for (int i = 0; i < cache.length; ++i) {
+      o = new Test8010927[one_card];
+      System.arraycopy(masterA, 0, o, 0, masterA.length);
+      cache[i] = o;
+    }
+    for (long j = 0; j < 256; ++j) {
+      o = new Long[10000]; // to trigger GC
+    }
+  }
+  static void testA_arraycopy() {
+    for (int i = 0; i < cache.length; ++i) {
+      System.arraycopy(masterA, 0, cache[i], 0, masterA.length);
+    }
+  }
+  static void testB_arraycopy() {
+    for (int i = 0; i < cache.length; ++i) {
+      System.arraycopy(masterB, 0, cache[i], 0, masterB.length);
+    }
+  }
+  static int get_top_address(long min, long max) {
+    int index = -1;
+    long addr = min;
+    for (int i = 0; i < cache.length; ++i) {
+      long test = wb.getObjectAddress(cache[i]);
+      if (((test - addr) > 0) && ((max - test) > 0)) { // substaction works with unsigned values
+        addr = test;
+        index = i;
+      }
+    }
+    return index;
+  }
+}
--- a/hotspot/test/runtime/7158804/Test7158804.sh	Wed May 29 10:16:32 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-
-##
-## @test Test7158804.sh
-## @bug 7158804
-## @summary Improve config file parsing
-## @run shell Test7158804.sh
-##
-if [ "${TESTSRC}" = "" ]
-then
-  TESTSRC=${PWD}
-  echo "TESTSRC not set.  Using "${TESTSRC}" as default"
-fi
-echo "TESTSRC=${TESTSRC}"
-## Adding common setup Variables for running shell tests.
-. ${TESTSRC}/../../test_env.sh
-
-rm -f .hotspotrc
-echo -XX:+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >.hotspotrc
-${TESTJAVA}/bin/java ${TESTVMOPTS} -XX:+IgnoreUnrecognizedVMOptions -XX:Flags=.hotspotrc -version
-if [ $? -ne 0 ]
-then
-    echo "Test Failed"
-    exit 1
-fi
-rm -f .hotspotrc
-exit 0
--- a/hotspot/test/runtime/8003985/Test8003985.java	Wed May 29 10:16:32 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,302 +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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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.BufferedReader;
-import java.io.InputStreamReader;
-import java.lang.Class;
-import java.lang.String;
-import java.lang.System;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CyclicBarrier;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import sun.misc.Unsafe;
-import sun.misc.Contended;
-
-/*
- * @test
- * @bug     8003985
- * @summary Support Contended Annotation - JEP 142
- *
- * @run main/othervm -XX:-RestrictContended Test8003985
- */
-public class Test8003985 {
-
-    private static final Unsafe U;
-    private static int ADDRESS_SIZE;
-    private static int HEADER_SIZE;
-
-    static {
-        // steal Unsafe
-        try {
-            Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
-            unsafe.setAccessible(true);
-            U = (Unsafe) unsafe.get(null);
-        } catch (NoSuchFieldException | IllegalAccessException e) {
-            throw new IllegalStateException(e);
-        }
-
-        // When running with CompressedOops on 64-bit platform, the address size
-        // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.
-        // Try to guess the reference field size with this naive trick.
-        try {
-            long off1 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj1"));
-            long off2 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj2"));
-            ADDRESS_SIZE = (int) Math.abs(off2 - off1);
-            HEADER_SIZE = (int) Math.min(off1, off2);
-        } catch (NoSuchFieldException e) {
-            ADDRESS_SIZE = -1;
-        }
-    }
-
-    static class CompressedOopsClass {
-        public Object obj1;
-        public Object obj2;
-    }
-
-    public static boolean arePaddedPairwise(Class klass, String field1, String field2) throws Exception {
-        Field f1 = klass.getDeclaredField(field1);
-        Field f2 = klass.getDeclaredField(field2);
-
-        if (isStatic(f1) != isStatic(f2)) {
-            return true; // these guys are in naturally disjoint locations
-        }
-
-        int diff = offset(f1) - offset(f2);
-        if (diff < 0) {
-            // f1 is first
-            return (offset(f2) - (offset(f1) + getSize(f1))) > 64;
-        } else {
-            // f2 is first
-            return (offset(f1) - (offset(f2) + getSize(f2))) > 64;
-        }
-    }
-
-    public static boolean isPadded(Class klass, String field1) throws Exception {
-        Field f1 = klass.getDeclaredField(field1);
-
-        if (isStatic(f1)) {
-            return offset(f1) > 128 + 64;
-        }
-
-        return offset(f1) > 64;
-    }
-
-    public static boolean sameLayout(Class klass1, Class klass2) throws Exception {
-        for (Field f1 : klass1.getDeclaredFields()) {
-            Field f2 = klass2.getDeclaredField(f1.getName());
-            if (offset(f1) != offset(f2)) {
-                return false;
-            }
-        }
-
-        for (Field f2 : klass1.getDeclaredFields()) {
-            Field f1 = klass2.getDeclaredField(f2.getName());
-            if (offset(f1) != offset(f2)) {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    public static boolean isStatic(Field field) {
-        return Modifier.isStatic(field.getModifiers());
-    }
-
-    public static int offset(Field field) {
-        if (isStatic(field)) {
-            return (int) U.staticFieldOffset(field);
-        } else {
-            return (int) U.objectFieldOffset(field);
-        }
-    }
-
-    public static int getSize(Field field) {
-        Class type = field.getType();
-        if (type == byte.class)    { return 1; }
-        if (type == boolean.class) { return 1; }
-        if (type == short.class)   { return 2; }
-        if (type == char.class)    { return 2; }
-        if (type == int.class)     { return 4; }
-        if (type == float.class)   { return 4; }
-        if (type == long.class)    { return 8; }
-        if (type == double.class)  { return 8; }
-        return ADDRESS_SIZE;
-    }
-
-    public static void main(String[] args) throws Exception {
-        boolean endResult = true;
-
-        // --------------- INSTANCE FIELDS ---------------------
-
-        if (arePaddedPairwise(Test1.class, "int1", "int2") ||
-                isPadded(Test1.class, "int1") ||
-                isPadded(Test1.class, "int2")) {
-            System.err.println("Test1 failed");
-            endResult &= false;
-        }
-
-        if (!arePaddedPairwise(Test2.class, "int1", "int2") ||
-                !isPadded(Test2.class, "int1") ||
-                isPadded(Test2.class, "int2")) {
-            System.err.println("Test2 failed");
-            endResult &= false;
-        }
-
-        if (!arePaddedPairwise(Test3.class, "int1", "int2") ||
-                !isPadded(Test3.class, "int1") ||
-                !isPadded(Test3.class, "int2")) {
-            System.err.println("Test3 failed");
-            endResult &= false;
-        }
-
-        if (arePaddedPairwise(Test4.class, "int1", "int2") ||
-                !isPadded(Test4.class, "int1") ||
-                !isPadded(Test4.class, "int2")) {
-            System.err.println("Test4 failed");
-            endResult &= false;
-        }
-
-        if (!arePaddedPairwise(Test5.class, "int1", "int2") ||
-                !isPadded(Test5.class, "int1") ||
-                !isPadded(Test5.class, "int2")) {
-            System.err.println("Test5 failed");
-            endResult &= false;
-        }
-
-        if (!arePaddedPairwise(Test6.class, "int1", "int2") ||
-                !isPadded(Test6.class, "int1") ||
-                !isPadded(Test6.class, "int2")) {
-            System.err.println("Test6 failed");
-            endResult &= false;
-        }
-
-        if (arePaddedPairwise(Test7.class, "int1", "int2") ||
-                !isPadded(Test7.class, "int1") ||
-                !isPadded(Test7.class, "int2")) {
-            System.err.println("Test7 failed");
-            endResult &= false;
-        }
-
-        if (!arePaddedPairwise(Test8.class, "int1", "int2") ||
-                !isPadded(Test8.class, "int1") ||
-                !isPadded(Test8.class, "int2")) {
-            System.err.println("Test8 failed");
-            endResult &= false;
-        }
-
-        if (!arePaddedPairwise(Test9.class, "int1", "int2") ||
-                !isPadded(Test9.class, "int1") ||
-                !isPadded(Test9.class, "int2")) {
-            System.err.println("Test9 failed");
-            endResult &= false;
-        }
-
-        if (!sameLayout(Test4.class, Test7.class)) {
-            System.err.println("Test4 and Test7 have different layouts");
-            endResult &= false;
-        }
-
-        if (!sameLayout(Test5.class, Test6.class)) {
-            System.err.println("Test5 and Test6 have different layouts");
-            endResult &= false;
-        }
-
-        if (!sameLayout(Test8.class, Test9.class)) {
-            System.err.println("Test8 and Test9 have different layouts");
-            endResult &= false;
-        }
-
-        System.out.println(endResult ? "Test PASSES" : "Test FAILS");
-        if (!endResult) {
-           throw new Error("Test failed");
-        }
-    }
-
-    // ----------------------------------- INSTANCE FIELDS -----------------------------------------
-
-    // naturally packed
-    public static class Test1 {
-                                 private int int1;
-                                 private int int2;
-    }
-
-    // int1 is padded
-    public static class Test2 {
-        @Contended               private int int1;
-                                 private int int2;
-    }
-
-    // both fields are padded
-    public static class Test3 {
-        @Contended               private int int1;
-        @Contended               private int int2;
-    }
-
-    // fields are padded in the singular group
-    public static class Test4 {
-        @Contended("sameGroup")  private int int1;
-        @Contended("sameGroup")  private int int2;
-    }
-
-    // fields are padded in disjoint groups
-    public static class Test5 {
-        @Contended("diffGroup1") private int int1;
-        @Contended("diffGroup2") private int int2;
-    }
-
-    // fields are padded in disjoint groups
-    public static class Test6 {
-        @Contended               private int int1;
-        @Contended("diffGroup2") private int int2;
-    }
-
-    // fields are padded in the singular group
-    @Contended
-    public static class Test7 {
-                                 private int int1;
-                                 private int int2;
-    }
-
-    // all fields are padded as the group, and one field is padded specifically
-    @Contended
-    public static class Test8 {
-        @Contended               private int int1;
-                                 private int int2;
-    }
-
-    // all fields are padded as the group, and one field is padded specifically
-    @Contended
-    public static class Test9 {
-        @Contended("group")      private int int1;
-                                 private int int2;
-    }
-
-}
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/CommandLine/ConfigFileParsing.java	Wed Jul 05 18:57:02 2017 +0200
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 ConfigFileParsing
+ * @bug 7158804
+ * @summary Improve config file parsing
+ * @library /testlibrary
+ */
+
+import java.io.PrintWriter;
+import com.oracle.java.testlibrary.*;
+
+public class ConfigFileParsing {
+  public static void main(String[] args) throws Exception {
+    String testFileName = ".hotspotrc";
+
+    // Create really long invalid option
+    String reallyLongInvalidOption = "";
+    for (int i=0; i<5000; i++)
+      reallyLongInvalidOption+='a';
+
+    // Populate the options file with really long string
+    PrintWriter pw = new PrintWriter(testFileName);
+    pw.println("-XX:+" + reallyLongInvalidOption);
+    pw.close();
+
+    // start VM
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+        "-XX:+IgnoreUnrecognizedVMOptions", "-XX:Flags=.hotspotrc", "-version");
+
+    OutputAnalyzer output = new OutputAnalyzer(pb.start());
+    output.shouldHaveExitValue(0);
+  }
+}
--- a/hotspot/test/runtime/RedefineObject/TestRedefineObject.java	Wed May 29 10:16:32 2013 -0700
+++ b/hotspot/test/runtime/RedefineObject/TestRedefineObject.java	Wed Jul 05 18:57:02 2017 +0200
@@ -32,10 +32,10 @@
  * @library /testlibrary
  * @build Agent
  * @run main ClassFileInstaller Agent
- * @run main Test
+ * @run main TestRedefineObject
  * @run main/othervm -javaagent:agent.jar Agent
  */
-public class Test {
+public class TestRedefineObject {
     public static void main(String[] args) throws Exception  {
 
       PrintWriter pw = new PrintWriter("MANIFEST.MF");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/contended/Basic.java	Wed Jul 05 18:57:02 2017 +0200
@@ -0,0 +1,302 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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.BufferedReader;
+import java.io.InputStreamReader;
+import java.lang.Class;
+import java.lang.String;
+import java.lang.System;
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CyclicBarrier;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import sun.misc.Unsafe;
+import sun.misc.Contended;
+
+/*
+ * @test
+ * @bug     8003985
+ * @summary Support Contended Annotation - JEP 142
+ *
+ * @run main/othervm -XX:-RestrictContended Basic
+ */
+public class Basic {
+
+    private static final Unsafe U;
+    private static int ADDRESS_SIZE;
+    private static int HEADER_SIZE;
+
+    static {
+        // steal Unsafe
+        try {
+            Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
+            unsafe.setAccessible(true);
+            U = (Unsafe) unsafe.get(null);
+        } catch (NoSuchFieldException | IllegalAccessException e) {
+            throw new IllegalStateException(e);
+        }
+
+        // When running with CompressedOops on 64-bit platform, the address size
+        // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.
+        // Try to guess the reference field size with this naive trick.
+        try {
+            long off1 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj1"));
+            long off2 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj2"));
+            ADDRESS_SIZE = (int) Math.abs(off2 - off1);
+            HEADER_SIZE = (int) Math.min(off1, off2);
+        } catch (NoSuchFieldException e) {
+            ADDRESS_SIZE = -1;
+        }
+    }
+
+    static class CompressedOopsClass {
+        public Object obj1;
+        public Object obj2;
+    }
+
+    public static boolean arePaddedPairwise(Class klass, String field1, String field2) throws Exception {
+        Field f1 = klass.getDeclaredField(field1);
+        Field f2 = klass.getDeclaredField(field2);
+
+        if (isStatic(f1) != isStatic(f2)) {
+            return true; // these guys are in naturally disjoint locations
+        }
+
+        int diff = offset(f1) - offset(f2);
+        if (diff < 0) {
+            // f1 is first
+            return (offset(f2) - (offset(f1) + getSize(f1))) > 64;
+        } else {
+            // f2 is first
+            return (offset(f1) - (offset(f2) + getSize(f2))) > 64;
+        }
+    }
+
+    public static boolean isPadded(Class klass, String field1) throws Exception {
+        Field f1 = klass.getDeclaredField(field1);
+
+        if (isStatic(f1)) {
+            return offset(f1) > 128 + 64;
+        }
+
+        return offset(f1) > 64;
+    }
+
+    public static boolean sameLayout(Class klass1, Class klass2) throws Exception {
+        for (Field f1 : klass1.getDeclaredFields()) {
+            Field f2 = klass2.getDeclaredField(f1.getName());
+            if (offset(f1) != offset(f2)) {
+                return false;
+            }
+        }
+
+        for (Field f2 : klass1.getDeclaredFields()) {
+            Field f1 = klass2.getDeclaredField(f2.getName());
+            if (offset(f1) != offset(f2)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean isStatic(Field field) {
+        return Modifier.isStatic(field.getModifiers());
+    }
+
+    public static int offset(Field field) {
+        if (isStatic(field)) {
+            return (int) U.staticFieldOffset(field);
+        } else {
+            return (int) U.objectFieldOffset(field);
+        }
+    }
+
+    public static int getSize(Field field) {
+        Class type = field.getType();
+        if (type == byte.class)    { return 1; }
+        if (type == boolean.class) { return 1; }
+        if (type == short.class)   { return 2; }
+        if (type == char.class)    { return 2; }
+        if (type == int.class)     { return 4; }
+        if (type == float.class)   { return 4; }
+        if (type == long.class)    { return 8; }
+        if (type == double.class)  { return 8; }
+        return ADDRESS_SIZE;
+    }
+
+    public static void main(String[] args) throws Exception {
+        boolean endResult = true;
+
+        // --------------- INSTANCE FIELDS ---------------------
+
+        if (arePaddedPairwise(Test1.class, "int1", "int2") ||
+                isPadded(Test1.class, "int1") ||
+                isPadded(Test1.class, "int2")) {
+            System.err.println("Test1 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(Test2.class, "int1", "int2") ||
+                !isPadded(Test2.class, "int1") ||
+                isPadded(Test2.class, "int2")) {
+            System.err.println("Test2 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(Test3.class, "int1", "int2") ||
+                !isPadded(Test3.class, "int1") ||
+                !isPadded(Test3.class, "int2")) {
+            System.err.println("Test3 failed");
+            endResult &= false;
+        }
+
+        if (arePaddedPairwise(Test4.class, "int1", "int2") ||
+                !isPadded(Test4.class, "int1") ||
+                !isPadded(Test4.class, "int2")) {
+            System.err.println("Test4 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(Test5.class, "int1", "int2") ||
+                !isPadded(Test5.class, "int1") ||
+                !isPadded(Test5.class, "int2")) {
+            System.err.println("Test5 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(Test6.class, "int1", "int2") ||
+                !isPadded(Test6.class, "int1") ||
+                !isPadded(Test6.class, "int2")) {
+            System.err.println("Test6 failed");
+            endResult &= false;
+        }
+
+        if (arePaddedPairwise(Test7.class, "int1", "int2") ||
+                !isPadded(Test7.class, "int1") ||
+                !isPadded(Test7.class, "int2")) {
+            System.err.println("Test7 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(Test8.class, "int1", "int2") ||
+                !isPadded(Test8.class, "int1") ||
+                !isPadded(Test8.class, "int2")) {
+            System.err.println("Test8 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(Test9.class, "int1", "int2") ||
+                !isPadded(Test9.class, "int1") ||
+                !isPadded(Test9.class, "int2")) {
+            System.err.println("Test9 failed");
+            endResult &= false;
+        }
+
+        if (!sameLayout(Test4.class, Test7.class)) {
+            System.err.println("Test4 and Test7 have different layouts");
+            endResult &= false;
+        }
+
+        if (!sameLayout(Test5.class, Test6.class)) {
+            System.err.println("Test5 and Test6 have different layouts");
+            endResult &= false;
+        }
+
+        if (!sameLayout(Test8.class, Test9.class)) {
+            System.err.println("Test8 and Test9 have different layouts");
+            endResult &= false;
+        }
+
+        System.out.println(endResult ? "Test PASSES" : "Test FAILS");
+        if (!endResult) {
+           throw new Error("Test failed");
+        }
+    }
+
+    // ----------------------------------- INSTANCE FIELDS -----------------------------------------
+
+    // naturally packed
+    public static class Test1 {
+                                 private int int1;
+                                 private int int2;
+    }
+
+    // int1 is padded
+    public static class Test2 {
+        @Contended               private int int1;
+                                 private int int2;
+    }
+
+    // both fields are padded
+    public static class Test3 {
+        @Contended               private int int1;
+        @Contended               private int int2;
+    }
+
+    // fields are padded in the singular group
+    public static class Test4 {
+        @Contended("sameGroup")  private int int1;
+        @Contended("sameGroup")  private int int2;
+    }
+
+    // fields are padded in disjoint groups
+    public static class Test5 {
+        @Contended("diffGroup1") private int int1;
+        @Contended("diffGroup2") private int int2;
+    }
+
+    // fields are padded in disjoint groups
+    public static class Test6 {
+        @Contended               private int int1;
+        @Contended("diffGroup2") private int int2;
+    }
+
+    // fields are padded in the singular group
+    @Contended
+    public static class Test7 {
+                                 private int int1;
+                                 private int int2;
+    }
+
+    // all fields are padded as the group, and one field is padded specifically
+    @Contended
+    public static class Test8 {
+        @Contended               private int int1;
+                                 private int int2;
+    }
+
+    // all fields are padded as the group, and one field is padded specifically
+    @Contended
+    public static class Test9 {
+        @Contended("group")      private int int1;
+                                 private int int2;
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/contended/DefaultValue.java	Wed Jul 05 18:57:02 2017 +0200
@@ -0,0 +1,185 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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.BufferedReader;
+import java.io.InputStreamReader;
+import java.lang.Class;
+import java.lang.String;
+import java.lang.System;
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CyclicBarrier;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import sun.misc.Unsafe;
+import sun.misc.Contended;
+
+/*
+ * @test
+ * @bug     8014509
+ * @summary \@Contended: explicit default value behaves differently from the implicit value
+ *
+ * @run main/othervm -XX:-RestrictContended DefaultValue
+ */
+public class DefaultValue {
+
+    private static final Unsafe U;
+    private static int ADDRESS_SIZE;
+    private static int HEADER_SIZE;
+
+    static {
+        // steal Unsafe
+        try {
+            Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
+            unsafe.setAccessible(true);
+            U = (Unsafe) unsafe.get(null);
+        } catch (NoSuchFieldException | IllegalAccessException e) {
+            throw new IllegalStateException(e);
+        }
+
+        // When running with CompressedOops on 64-bit platform, the address size
+        // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.
+        // Try to guess the reference field size with this naive trick.
+        try {
+            long off1 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj1"));
+            long off2 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj2"));
+            ADDRESS_SIZE = (int) Math.abs(off2 - off1);
+            HEADER_SIZE = (int) Math.min(off1, off2);
+        } catch (NoSuchFieldException e) {
+            ADDRESS_SIZE = -1;
+        }
+    }
+
+    static class CompressedOopsClass {
+        public Object obj1;
+        public Object obj2;
+    }
+
+    public static boolean arePaddedPairwise(Class klass, String field1, String field2) throws Exception {
+        Field f1 = klass.getField(field1);
+        Field f2 = klass.getField(field2);
+
+        int diff = offset(f1) - offset(f2);
+        if (diff < 0) {
+            // f1 is first
+            return (offset(f2) - (offset(f1) + getSize(f1))) > 64;
+        } else {
+            // f2 is first
+            return (offset(f1) - (offset(f2) + getSize(f2))) > 64;
+        }
+    }
+
+    public static boolean sameLayout(Class klass1, Class klass2) throws Exception {
+        for (Field f1 : klass1.getDeclaredFields()) {
+            Field f2 = klass2.getDeclaredField(f1.getName());
+            if (offset(f1) != offset(f2)) {
+                return false;
+            }
+        }
+
+        for (Field f2 : klass1.getDeclaredFields()) {
+            Field f1 = klass2.getDeclaredField(f2.getName());
+            if (offset(f1) != offset(f2)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean isStatic(Field field) {
+        return Modifier.isStatic(field.getModifiers());
+    }
+
+    public static int offset(Field field) {
+        if (isStatic(field)) {
+            return (int) U.staticFieldOffset(field);
+        } else {
+            return (int) U.objectFieldOffset(field);
+        }
+    }
+
+    public static int getSize(Field field) {
+        Class type = field.getType();
+        if (type == byte.class)    { return 1; }
+        if (type == boolean.class) { return 1; }
+        if (type == short.class)   { return 2; }
+        if (type == char.class)    { return 2; }
+        if (type == int.class)     { return 4; }
+        if (type == float.class)   { return 4; }
+        if (type == long.class)    { return 8; }
+        if (type == double.class)  { return 8; }
+        return ADDRESS_SIZE;
+    }
+
+    public static void main(String[] args) throws Exception {
+        boolean endResult = true;
+
+        if (!arePaddedPairwise(R1.class, "int1", "int2")) {
+            System.err.println("R1 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(R2.class, "int1", "int2")) {
+            System.err.println("R2 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(R3.class, "int1", "int2")) {
+            System.err.println("R3 failed");
+            endResult &= false;
+        }
+
+        System.out.println(endResult ? "Test PASSES" : "Test FAILS");
+        if (!endResult) {
+           throw new Error("Test failed");
+        }
+    }
+
+    public static class R1 {
+        @Contended
+        public int int1;
+        @Contended
+        public int int2;
+    }
+
+    public static class R2 {
+        @Contended("")
+        public int int1;
+        @Contended("")
+        public int int2;
+    }
+
+    public static class R3 {
+        @Contended()
+        public int int1;
+        @Contended()
+        public int int2;
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/contended/Inheritance1.java	Wed Jul 05 18:57:02 2017 +0200
@@ -0,0 +1,248 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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.BufferedReader;
+import java.io.InputStreamReader;
+import java.lang.Class;
+import java.lang.String;
+import java.lang.System;
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CyclicBarrier;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import sun.misc.Unsafe;
+import sun.misc.Contended;
+
+/*
+ * @test
+ * @bug     8012939
+ * @summary \@Contended doesn't work correctly with inheritance
+ *
+ * @run main/othervm -XX:-RestrictContended Inheritance1
+ */
+public class Inheritance1 {
+
+    private static final Unsafe U;
+    private static int ADDRESS_SIZE;
+    private static int HEADER_SIZE;
+
+    static {
+        // steal Unsafe
+        try {
+            Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
+            unsafe.setAccessible(true);
+            U = (Unsafe) unsafe.get(null);
+        } catch (NoSuchFieldException | IllegalAccessException e) {
+            throw new IllegalStateException(e);
+        }
+
+        // When running with CompressedOops on 64-bit platform, the address size
+        // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.
+        // Try to guess the reference field size with this naive trick.
+        try {
+            long off1 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj1"));
+            long off2 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj2"));
+            ADDRESS_SIZE = (int) Math.abs(off2 - off1);
+            HEADER_SIZE = (int) Math.min(off1, off2);
+        } catch (NoSuchFieldException e) {
+            ADDRESS_SIZE = -1;
+        }
+    }
+
+    static class CompressedOopsClass {
+        public Object obj1;
+        public Object obj2;
+    }
+
+    public static boolean arePaddedPairwise(Class klass, String field1, String field2) throws Exception {
+        Field f1 = klass.getField(field1);
+        Field f2 = klass.getField(field2);
+
+        int diff = offset(f1) - offset(f2);
+        if (diff < 0) {
+            // f1 is first
+            return (offset(f2) - (offset(f1) + getSize(f1))) > 64;
+        } else {
+            // f2 is first
+            return (offset(f1) - (offset(f2) + getSize(f2))) > 64;
+        }
+    }
+
+    public static boolean sameLayout(Class klass1, Class klass2) throws Exception {
+        for (Field f1 : klass1.getDeclaredFields()) {
+            Field f2 = klass2.getDeclaredField(f1.getName());
+            if (offset(f1) != offset(f2)) {
+                return false;
+            }
+        }
+
+        for (Field f2 : klass1.getDeclaredFields()) {
+            Field f1 = klass2.getDeclaredField(f2.getName());
+            if (offset(f1) != offset(f2)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean isStatic(Field field) {
+        return Modifier.isStatic(field.getModifiers());
+    }
+
+    public static int offset(Field field) {
+        if (isStatic(field)) {
+            return (int) U.staticFieldOffset(field);
+        } else {
+            return (int) U.objectFieldOffset(field);
+        }
+    }
+
+    public static int getSize(Field field) {
+        Class type = field.getType();
+        if (type == byte.class)    { return 1; }
+        if (type == boolean.class) { return 1; }
+        if (type == short.class)   { return 2; }
+        if (type == char.class)    { return 2; }
+        if (type == int.class)     { return 4; }
+        if (type == float.class)   { return 4; }
+        if (type == long.class)    { return 8; }
+        if (type == double.class)  { return 8; }
+        return ADDRESS_SIZE;
+    }
+
+    public static void main(String[] args) throws Exception {
+        boolean endResult = true;
+
+        // --------------- INSTANCE FIELDS ---------------------
+
+        if (!arePaddedPairwise(A2_R1.class, "int1", "int2")) {
+            System.err.println("A2_R1 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(A3_R1.class, "int1", "int2")) {
+            System.err.println("A3_R1 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(A1_R2.class, "int1", "int2")) {
+            System.err.println("A1_R2 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(A2_R2.class, "int1", "int2")) {
+            System.err.println("A2_R2 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(A3_R2.class, "int1", "int2")) {
+            System.err.println("A3_R2 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(A1_R3.class, "int1", "int2")) {
+            System.err.println("A1_R3 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(A2_R3.class, "int1", "int2")) {
+            System.err.println("A2_R3 failed");
+            endResult &= false;
+        }
+
+        if (!arePaddedPairwise(A3_R3.class, "int1", "int2")) {
+            System.err.println("A3_R3 failed");
+            endResult &= false;
+        }
+
+        System.out.println(endResult ? "Test PASSES" : "Test FAILS");
+        if (!endResult) {
+           throw new Error("Test failed");
+        }
+    }
+
+    public static class R1 {
+        public int int1;
+    }
+
+    public static class R2 {
+        @Contended
+        public int int1;
+    }
+
+    @Contended
+    public static class R3 {
+        public int int1;
+    }
+
+    public static class A1_R1 extends R1 {
+        public int int2;
+    }
+
+    public static class A2_R1 extends R1 {
+        @Contended
+        public int int2;
+    }
+
+    @Contended
+    public static class A3_R1 extends R1 {
+        public int int2;
+    }
+
+    public static class A1_R2 extends R2 {
+        public int int2;
+    }
+
+    public static class A2_R2 extends R2 {
+        @Contended
+        public int int2;
+    }
+
+    @Contended
+    public static class A3_R2 extends R2 {
+        public int int2;
+    }
+
+    public static class A1_R3 extends R3 {
+        public int int2;
+    }
+
+    public static class A2_R3 extends R3 {
+        @Contended
+        public int int2;
+    }
+
+    @Contended
+    public static class A3_R3 extends R3 {
+        public int int2;
+    }
+
+
+}
+
--- a/jaxp/.hgtags	Wed May 29 10:16:32 2013 -0700
+++ b/jaxp/.hgtags	Wed Jul 05 18:57:02 2017 +0200
@@ -212,3 +212,4 @@
 7122f7bb0fcc8a39e5254402119b2ee3fa0ad313 jdk8-b88
 893d2ba8bbea3a8d090e51d8eaea285b390789ea jdk8-b89
 668acc0e1034bc1bec6d02be92e0dd4a63d0667e jdk8-b90
+e3065fb07877c7e96e8b93416fe2ab9a4c9eb2a5 jdk8-b91
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Wed May 29 10:16:32 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
--- a/jaxws/.hgtags	Wed May 29 10:16:32 2013 -0700
+++ b/jaxws/.hgtags	Wed Jul 05 18:57:02 2017 +0200
@@ -212,3 +212,4 @@
 24fa5452e5d4e9df8b85196283275a6ca4b4adb4 jdk8-b88
 88838e08e4ef6a254867c8126070a1975683108d jdk8-b89
 3e5b9ea5ac35ea7096da484e24a863cf4552179f jdk8-b90
+0bb1a9fa56b037d072efdaae5f5b73a0f23c966c jdk8-b91
--- a/jdk/.hgtags	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/.hgtags	Wed Jul 05 18:57:02 2017 +0200
@@ -212,3 +212,4 @@
 8dbb4b159e04de3c447c9242c70505e71f8624c7 jdk8-b88
 845025546e35519fbb8970e79fc2a834063a5e19 jdk8-b89
 c63eda8f63008a4398d2c22ac8d72f7fef6f9238 jdk8-b90
+169451cf0cc53bde5af24f9820ea3f35ec4b4df4 jdk8-b91
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/FillableStringTest.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/FillableStringTest.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/MapTest.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/MapTest.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/MethodReferenceTestInstanceMethod.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/MethodReferenceTestInstanceMethod.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/MethodReferenceTestKinds.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/MethodReferenceTestKinds.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/MethodReferenceTestSueCase1.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/MethodReferenceTestSueCase1.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/MethodReferenceTestSueCase2.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/MethodReferenceTestSueCase2.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/MethodReferenceTestSueCase4.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/MethodReferenceTestSueCase4.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/separate/AttributeInjector.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/separate/AttributeInjector.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/separate/ClassFile.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/separate/ClassFile.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/separate/ClassFilePreprocessor.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/separate/ClassFilePreprocessor.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/separate/ClassToInterfaceConverter.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/separate/ClassToInterfaceConverter.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/separate/Compiler.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/separate/Compiler.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/separate/DirectedClassLoader.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/separate/DirectedClassLoader.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/separate/SourceModel.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/separate/SourceModel.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/separate/TestHarness.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/separate/TestHarness.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/vm/DefaultMethodRegressionTests.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/vm/DefaultMethodRegressionTests.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/vm/DefaultMethodsTest.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/vm/DefaultMethodsTest.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/jdk/test/jdk/lambda/vm/InterfaceAccessFlagsTest.java	Wed May 29 10:16:32 2013 -0700
+++ b/jdk/test/jdk/lambda/vm/InterfaceAccessFlagsTest.java	Wed Jul 05 18:57:02 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
--- a/nashorn/.hgtags	Wed May 29 10:16:32 2013 -0700
+++ b/nashorn/.hgtags	Wed Jul 05 18:57:02 2017 +0200
@@ -200,3 +200,4 @@
 40c107d1ae6f81a62e35dfe618b827897405e9b2 jdk8-b88
 45ce27fbe2720d80070095c0db7344ec41e2833d jdk8-b89
 67ca019e3713dd71c884d753de02fd0021981969 jdk8-b90
+6b9f4120380091b8b1751a825b9f84bf1be224fe jdk8-b91