Merge
authorduke
Wed, 05 Jul 2017 19:58:21 +0200
changeset 26187 b50907e0a329
parent 26186 dc0034c79fa4 (current diff)
parent 26133 f1c3d5352210 (diff)
child 26229 b1d885c12096
Merge
make/common/SetupJava.gmk
--- a/.hgtags-top-repo	Fri Aug 29 11:57:22 2014 -0700
+++ b/.hgtags-top-repo	Wed Jul 05 19:58:21 2017 +0200
@@ -270,3 +270,4 @@
 aefd8899a8d6615fb34ba99b2e38996a7145baa8 jdk9-b25
 d3ec8d048e6c3c46b6e0ee011cc551ad386dfba5 jdk9-b26
 ba5645f2735b41ed085d07ba20fa7b322afff318 jdk9-b27
+ea2f7981236f3812436958748ab3d26e80a35130 jdk9-b28
--- a/Makefile	Fri Aug 29 11:57:22 2014 -0700
+++ b/Makefile	Wed Jul 05 19:58:21 2017 +0200
@@ -136,10 +136,12 @@
 	$(info .  make docs              # Create all docs)
 	$(info .  make docs-javadoc      # Create just javadocs, depends on less than full docs)
 	$(info .  make profiles          # Create complete j2re compact profile images)
-	$(info .  make bootcycle-images  # Build images twice, second time with newly build JDK)
+	$(info .  make bootcycle-images  # Build images twice, second time with newly built JDK)
 	$(info .  make install           # Install the generated images locally)
 	$(info .  make clean             # Remove all files generated by make, but not those)
-	$(info .                         # generated by configure)
+	$(info .                         # generated by configure. Do not run clean and other)
+	$(info .                         # targets together as that might behave in an)
+	$(info .                         # unexpected way.)
 	$(info .  make dist-clean        # Remove all files, including configuration)
 	$(info .  make help              # Give some help on using make)
 	$(info .  make test              # Run tests, default is all tests (see TEST below))
--- a/common/autoconf/basics.m4	Fri Aug 29 11:57:22 2014 -0700
+++ b/common/autoconf/basics.m4	Wed Jul 05 19:58:21 2017 +0200
@@ -849,7 +849,12 @@
   if test -f $DELETEDIR/TestIfFindSupportsDelete; then
     # No, it does not.
     rm $DELETEDIR/TestIfFindSupportsDelete
-    FIND_DELETE="-exec rm \{\} \+"
+    if test "x$OPENJDK_TARGET_OS" = "xaix"; then
+      # AIX 'find' is buggy if called with '-exec {} \+' and an empty file list
+      FIND_DELETE="-print | xargs rm"
+    else
+      FIND_DELETE="-exec rm \{\} \+"
+    fi
     AC_MSG_RESULT([no])
   else
     AC_MSG_RESULT([yes])
--- a/common/autoconf/boot-jdk.m4	Fri Aug 29 11:57:22 2014 -0700
+++ b/common/autoconf/boot-jdk.m4	Wed Jul 05 19:58:21 2017 +0200
@@ -370,18 +370,27 @@
 
   # Maximum amount of heap memory.
   # Maximum stack size.
+  JVM_MAX_HEAP=`expr $MEMORY_SIZE / 2`
   if test "x$BUILD_NUM_BITS" = x32; then
-    JVM_MAX_HEAP=1100M
+    if test "$JVM_MAX_HEAP" -gt "1100"; then
+      JVM_MAX_HEAP=1100
+    elif test "$JVM_MAX_HEAP" -lt "512"; then
+      JVM_MAX_HEAP=512
+    fi
     STACK_SIZE=768
   else
     # Running Javac on a JVM on a 64-bit machine, takes more space since 64-bit
     # pointers are used. Apparently, we need to increase the heap and stack
     # space for the jvm. More specifically, when running javac to build huge
     # jdk batch
-    JVM_MAX_HEAP=1600M
+    if test "$JVM_MAX_HEAP" -gt "1600"; then
+      JVM_MAX_HEAP=1600
+    elif test "$JVM_MAX_HEAP" -lt "512"; then
+      JVM_MAX_HEAP=512
+    fi
     STACK_SIZE=1536
   fi
-  ADD_JVM_ARG_IF_OK([-Xmx$JVM_MAX_HEAP],boot_jdk_jvmargs_big,[$JAVA])
+  ADD_JVM_ARG_IF_OK([-Xmx${JVM_MAX_HEAP}M],boot_jdk_jvmargs_big,[$JAVA])
   ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs_big,[$JAVA])
 
   AC_MSG_RESULT([$boot_jdk_jvmargs_big])
--- a/common/autoconf/build-performance.m4	Fri Aug 29 11:57:22 2014 -0700
+++ b/common/autoconf/build-performance.m4	Wed Jul 05 19:58:21 2017 +0200
@@ -131,8 +131,8 @@
   if test "x$with_jobs" = x; then
     # Number of jobs was not specified, calculate.
     AC_MSG_CHECKING([for appropriate number of jobs to run in parallel])
-    # Approximate memory in GB, rounding up a bit.
-    memory_gb=`expr $MEMORY_SIZE / 1100`
+    # Approximate memory in GB.
+    memory_gb=`expr $MEMORY_SIZE / 1024`
     # Pick the lowest of memory in gb and number of cores.
     if test "$memory_gb" -lt "$NUM_CORES"; then
       JOBS="$memory_gb"
@@ -291,16 +291,11 @@
       AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA])
     fi
   else
-    SJAVAC_SERVER_JAVA=""
-    # Hotspot specific options.
-    ADD_JVM_ARG_IF_OK([-verbosegc],SJAVAC_SERVER_JAVA,[$JAVA])
-    # JRockit specific options.
-    ADD_JVM_ARG_IF_OK([-Xverbose:gc],SJAVAC_SERVER_JAVA,[$JAVA])
-    SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA"
+    SJAVAC_SERVER_JAVA="$JAVA"
   fi
   AC_SUBST(SJAVAC_SERVER_JAVA)
 
-  if test "$MEMORY_SIZE" -gt "2500"; then
+  if test "$MEMORY_SIZE" -gt "3000"; then
     ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
     if test "$JVM_ARG_OK" = true; then
       JVM_64BIT=true
@@ -308,34 +303,33 @@
     fi
   fi
 
+  MX_VALUE=`expr $MEMORY_SIZE / 2`
   if test "$JVM_64BIT" = true; then
-    if test "$MEMORY_SIZE" -gt "17000"; then
-      ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
+    # Set ms lower than mx since more than one instance of the server might
+    # get launched at the same time before they figure out which instance won.
+    MS_VALUE=512
+    if test "$MX_VALUE" -gt "2048"; then
+      MX_VALUE=2048
     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])
-    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])
-    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])
+  else
+    MS_VALUE=256
+    if test "$MX_VALUE" -gt "1500"; then
+      MX_VALUE=1500
     fi
   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])
+  if test "$MX_VALUE" -lt "512"; then
+    MX_VALUE=512
   fi
-  if test "$JVM_ARG_OK" = false; then
-    ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
-  fi
+  ADD_JVM_ARG_IF_OK([-Xms${MS_VALUE}M -Xmx${MX_VALUE}M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
 
-  AC_MSG_CHECKING([whether to use sjavac])
   AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac],
       [use sjavac to do fast incremental compiles @<:@disabled@:>@])],
       [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no'])
+  if test "x$JVM_ARG_OK" = "xfalse"; then
+    AC_MSG_WARN([Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling sjavac])
+    ENABLE_SJAVAC=no;
+  fi
+  AC_MSG_CHECKING([whether to use sjavac])
   AC_MSG_RESULT([$ENABLE_SJAVAC])
   AC_SUBST(ENABLE_SJAVAC)
 
--- a/common/autoconf/configure.ac	Fri Aug 29 11:57:22 2014 -0700
+++ b/common/autoconf/configure.ac	Wed Jul 05 19:58:21 2017 +0200
@@ -142,7 +142,6 @@
 ###############################################################################
 
 BOOTJDK_SETUP_BOOT_JDK
-BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS
 
 ###############################################################################
 #
@@ -233,6 +232,9 @@
 BPERF_SETUP_BUILD_MEMORY
 BPERF_SETUP_BUILD_JOBS
 
+# Setup arguments for the boot jdk (after cores and memory have been setup)
+BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS
+
 # Setup smart javac (after cores and memory have been setup)
 BPERF_SETUP_SMART_JAVAC
 
--- a/common/autoconf/flags.m4	Fri Aug 29 11:57:22 2014 -0700
+++ b/common/autoconf/flags.m4	Wed Jul 05 19:58:21 2017 +0200
@@ -342,17 +342,15 @@
       # no adjustment
       ;;
     fastdebug )
-      # Add compile time bounds checks.
-      CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1"
-      CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1"
+      # no adjustment
       ;;
     slowdebug )
-      # Add runtime bounds checks and symbol info.
-      CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1"
-      CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1"
+      # Add runtime stack smashing and undefined behavior checks
+      CFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
+      CXXFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
       if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then
         CFLAGS_DEBUG_OPTIONS="$CFLAGS_DEBUG_OPTIONS  $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG"
-        CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG"
+        CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIsOR_FLAG"
       fi
       ;;
     esac
--- a/common/autoconf/generated-configure.sh	Fri Aug 29 11:57:22 2014 -0700
+++ b/common/autoconf/generated-configure.sh	Wed Jul 05 19:58:21 2017 +0200
@@ -634,6 +634,10 @@
 SJAVAC_SERVER_DIR
 ENABLE_SJAVAC
 SJAVAC_SERVER_JAVA
+JAVA_TOOL_FLAGS_SMALL
+JAVA_FLAGS_SMALL
+JAVA_FLAGS_BIG
+JAVA_FLAGS
 JOBS
 MEMORY_SIZE
 NUM_CORES
@@ -805,10 +809,6 @@
 JAXP_TOPDIR
 CORBA_TOPDIR
 LANGTOOLS_TOPDIR
-JAVA_TOOL_FLAGS_SMALL
-JAVA_FLAGS_SMALL
-JAVA_FLAGS_BIG
-JAVA_FLAGS
 JAVAC_FLAGS
 BOOT_JDK_SOURCETARGET
 JARSIGNER
@@ -1064,7 +1064,6 @@
 with_user_release_suffix
 with_build_number
 with_boot_jdk
-with_boot_jdk_jvmargs
 with_add_source_root
 with_override_source_root
 with_adds_and_overrides
@@ -1106,6 +1105,7 @@
 with_num_cores
 with_memory_size
 with_jobs
+with_boot_jdk_jvmargs
 with_sjavac_server_java
 enable_sjavac
 enable_precompiled_headers
@@ -1904,10 +1904,6 @@
                           number is not set.[username_builddateb00]
   --with-build-number     Set build number value for build [b00]
   --with-boot-jdk         path to Boot JDK (used to bootstrap build) [probed]
-  --with-boot-jdk-jvmargs specify JVM arguments to be passed to all java
-                          invocations of boot JDK, overriding the default
-                          values, e.g --with-boot-jdk-jvmargs="-Xmx8G
-                          -enableassertions"
   --with-add-source-root  for each and every source directory, look in this
                           additional source root for the same directory; if it
                           exists and have files in it, include it in the build
@@ -1979,6 +1975,10 @@
                           --with-memory-size=1024 [probed]
   --with-jobs             number of parallel jobs to let make run [calculated
                           based on cores and memory]
+  --with-boot-jdk-jvmargs specify JVM arguments to be passed to all java
+                          invocations of boot JDK, overriding the default
+                          values, e.g --with-boot-jdk-jvmargs="-Xmx8G
+                          -enableassertions"
   --with-sjavac-server-java
                           use this java binary for running the sjavac
                           background server [Boot JDK java]
@@ -4321,7 +4321,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1408448519
+DATE_WHEN_GENERATED=1409311712
 
 ###############################################################################
 #
@@ -17284,7 +17284,12 @@
   if test -f $DELETEDIR/TestIfFindSupportsDelete; then
     # No, it does not.
     rm $DELETEDIR/TestIfFindSupportsDelete
-    FIND_DELETE="-exec rm \{\} \+"
+    if test "x$OPENJDK_TARGET_OS" = "xaix"; then
+      # AIX 'find' is buggy if called with '-exec {} \+' and an empty file list
+      FIND_DELETE="-print | xargs rm"
+    else
+      FIND_DELETE="-exec rm \{\} \+"
+    fi
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
   else
@@ -26315,197 +26320,6 @@
 
 
 
-  ##############################################################################
-  #
-  # Specify jvm options for anything that is run with the Boot JDK.
-  # Not all JVM:s accept the same arguments on the command line.
-  #
-
-# Check whether --with-boot-jdk-jvmargs was given.
-if test "${with_boot_jdk_jvmargs+set}" = set; then :
-  withval=$with_boot_jdk_jvmargs;
-fi
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command " >&5
-$as_echo_n "checking flags for boot jdk java command ... " >&6; }
-
-  # Disable special log output when a debug build is used as Boot JDK...
-
-  $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
-
-
-  # Apply user provided options.
-
-  $ECHO "Check if jvm arg is ok: $with_boot_jdk_jvmargs" >&5
-  $ECHO "Command: $JAVA $with_boot_jdk_jvmargs -version" >&5
-  OUTPUT=`$JAVA $with_boot_jdk_jvmargs -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 $with_boot_jdk_jvmargs"
-    JVM_ARG_OK=true
-  else
-    $ECHO "Arg failed:" >&5
-    $ECHO "$OUTPUT" >&5
-    JVM_ARG_OK=false
-  fi
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs" >&5
-$as_echo "$boot_jdk_jvmargs" >&6; }
-
-  # For now, general JAVA_FLAGS are the same as the boot jdk jvmargs
-  JAVA_FLAGS=$boot_jdk_jvmargs
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command for big workloads" >&5
-$as_echo_n "checking flags for boot jdk java command for big workloads... " >&6; }
-
-  # Starting amount of heap memory.
-
-  $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_big="$boot_jdk_jvmargs_big -Xms64M"
-    JVM_ARG_OK=true
-  else
-    $ECHO "Arg failed:" >&5
-    $ECHO "$OUTPUT" >&5
-    JVM_ARG_OK=false
-  fi
-
-
-  # Maximum amount of heap memory.
-  # Maximum stack size.
-  if test "x$BUILD_NUM_BITS" = x32; then
-    JVM_MAX_HEAP=1100M
-    STACK_SIZE=768
-  else
-    # Running Javac on a JVM on a 64-bit machine, takes more space since 64-bit
-    # pointers are used. Apparently, we need to increase the heap and stack
-    # space for the jvm. More specifically, when running javac to build huge
-    # jdk batch
-    JVM_MAX_HEAP=1600M
-    STACK_SIZE=1536
-  fi
-
-  $ECHO "Check if jvm arg is ok: -Xmx$JVM_MAX_HEAP" >&5
-  $ECHO "Command: $JAVA -Xmx$JVM_MAX_HEAP -version" >&5
-  OUTPUT=`$JAVA -Xmx$JVM_MAX_HEAP -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_big="$boot_jdk_jvmargs_big -Xmx$JVM_MAX_HEAP"
-    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_big="$boot_jdk_jvmargs_big -XX:ThreadStackSize=$STACK_SIZE"
-    JVM_ARG_OK=true
-  else
-    $ECHO "Arg failed:" >&5
-    $ECHO "$OUTPUT" >&5
-    JVM_ARG_OK=false
-  fi
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs_big" >&5
-$as_echo "$boot_jdk_jvmargs_big" >&6; }
-
-  JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command for small workloads" >&5
-$as_echo_n "checking flags for boot jdk java command for small workloads... " >&6; }
-
-  # Use serial gc for small short lived tools if possible
-
-  $ECHO "Check if jvm arg is ok: -XX:+UseSerialGC" >&5
-  $ECHO "Command: $JAVA -XX:+UseSerialGC -version" >&5
-  OUTPUT=`$JAVA -XX:+UseSerialGC -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_small="$boot_jdk_jvmargs_small -XX:+UseSerialGC"
-    JVM_ARG_OK=true
-  else
-    $ECHO "Arg failed:" >&5
-    $ECHO "$OUTPUT" >&5
-    JVM_ARG_OK=false
-  fi
-
-
-  $ECHO "Check if jvm arg is ok: -Xms32M" >&5
-  $ECHO "Command: $JAVA -Xms32M -version" >&5
-  OUTPUT=`$JAVA -Xms32M -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_small="$boot_jdk_jvmargs_small -Xms32M"
-    JVM_ARG_OK=true
-  else
-    $ECHO "Arg failed:" >&5
-    $ECHO "$OUTPUT" >&5
-    JVM_ARG_OK=false
-  fi
-
-
-  $ECHO "Check if jvm arg is ok: -Xmx512M" >&5
-  $ECHO "Command: $JAVA -Xmx512M -version" >&5
-  OUTPUT=`$JAVA -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
-    boot_jdk_jvmargs_small="$boot_jdk_jvmargs_small -Xmx512M"
-    JVM_ARG_OK=true
-  else
-    $ECHO "Arg failed:" >&5
-    $ECHO "$OUTPUT" >&5
-    JVM_ARG_OK=false
-  fi
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs_small" >&5
-$as_echo "$boot_jdk_jvmargs_small" >&6; }
-
-  JAVA_FLAGS_SMALL=$boot_jdk_jvmargs_small
-
-
-  JAVA_TOOL_FLAGS_SMALL=""
-  for f in $JAVA_FLAGS_SMALL; do
-    JAVA_TOOL_FLAGS_SMALL="$JAVA_TOOL_FLAGS_SMALL -J$f"
-  done
-
-
-
 ###############################################################################
 #
 # Configure the sources to use. We can add or override individual directories.
@@ -42515,17 +42329,15 @@
       # no adjustment
       ;;
     fastdebug )
-      # Add compile time bounds checks.
-      CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1"
-      CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1"
+      # no adjustment
       ;;
     slowdebug )
-      # Add runtime bounds checks and symbol info.
-      CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1"
-      CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1"
+      # Add runtime stack smashing and undefined behavior checks
+      CFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
+      CXXFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
       if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then
         CFLAGS_DEBUG_OPTIONS="$CFLAGS_DEBUG_OPTIONS  $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG"
-        CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG"
+        CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIsOR_FLAG"
       fi
       ;;
     esac
@@ -49884,8 +49696,8 @@
     # Number of jobs was not specified, calculate.
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for appropriate number of jobs to run in parallel" >&5
 $as_echo_n "checking for appropriate number of jobs to run in parallel... " >&6; }
-    # Approximate memory in GB, rounding up a bit.
-    memory_gb=`expr $MEMORY_SIZE / 1100`
+    # Approximate memory in GB.
+    memory_gb=`expr $MEMORY_SIZE / 1024`
     # Pick the lowest of memory in gb and number of cores.
     if test "$memory_gb" -lt "$NUM_CORES"; then
       JOBS="$memory_gb"
@@ -49911,6 +49723,208 @@
 
 
 
+# Setup arguments for the boot jdk (after cores and memory have been setup)
+
+  ##############################################################################
+  #
+  # Specify jvm options for anything that is run with the Boot JDK.
+  # Not all JVM:s accept the same arguments on the command line.
+  #
+
+# Check whether --with-boot-jdk-jvmargs was given.
+if test "${with_boot_jdk_jvmargs+set}" = set; then :
+  withval=$with_boot_jdk_jvmargs;
+fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command " >&5
+$as_echo_n "checking flags for boot jdk java command ... " >&6; }
+
+  # Disable special log output when a debug build is used as Boot JDK...
+
+  $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
+
+
+  # Apply user provided options.
+
+  $ECHO "Check if jvm arg is ok: $with_boot_jdk_jvmargs" >&5
+  $ECHO "Command: $JAVA $with_boot_jdk_jvmargs -version" >&5
+  OUTPUT=`$JAVA $with_boot_jdk_jvmargs -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 $with_boot_jdk_jvmargs"
+    JVM_ARG_OK=true
+  else
+    $ECHO "Arg failed:" >&5
+    $ECHO "$OUTPUT" >&5
+    JVM_ARG_OK=false
+  fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs" >&5
+$as_echo "$boot_jdk_jvmargs" >&6; }
+
+  # For now, general JAVA_FLAGS are the same as the boot jdk jvmargs
+  JAVA_FLAGS=$boot_jdk_jvmargs
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command for big workloads" >&5
+$as_echo_n "checking flags for boot jdk java command for big workloads... " >&6; }
+
+  # Starting amount of heap memory.
+
+  $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_big="$boot_jdk_jvmargs_big -Xms64M"
+    JVM_ARG_OK=true
+  else
+    $ECHO "Arg failed:" >&5
+    $ECHO "$OUTPUT" >&5
+    JVM_ARG_OK=false
+  fi
+
+
+  # Maximum amount of heap memory.
+  # Maximum stack size.
+  JVM_MAX_HEAP=`expr $MEMORY_SIZE / 2`
+  if test "x$BUILD_NUM_BITS" = x32; then
+    if test "$JVM_MAX_HEAP" -gt "1100"; then
+      JVM_MAX_HEAP=1100
+    elif test "$JVM_MAX_HEAP" -lt "512"; then
+      JVM_MAX_HEAP=512
+    fi
+    STACK_SIZE=768
+  else
+    # Running Javac on a JVM on a 64-bit machine, takes more space since 64-bit
+    # pointers are used. Apparently, we need to increase the heap and stack
+    # space for the jvm. More specifically, when running javac to build huge
+    # jdk batch
+    if test "$JVM_MAX_HEAP" -gt "1600"; then
+      JVM_MAX_HEAP=1600
+    elif test "$JVM_MAX_HEAP" -lt "512"; then
+      JVM_MAX_HEAP=512
+    fi
+    STACK_SIZE=1536
+  fi
+
+  $ECHO "Check if jvm arg is ok: -Xmx${JVM_MAX_HEAP}M" >&5
+  $ECHO "Command: $JAVA -Xmx${JVM_MAX_HEAP}M -version" >&5
+  OUTPUT=`$JAVA -Xmx${JVM_MAX_HEAP}M -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_big="$boot_jdk_jvmargs_big -Xmx${JVM_MAX_HEAP}M"
+    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_big="$boot_jdk_jvmargs_big -XX:ThreadStackSize=$STACK_SIZE"
+    JVM_ARG_OK=true
+  else
+    $ECHO "Arg failed:" >&5
+    $ECHO "$OUTPUT" >&5
+    JVM_ARG_OK=false
+  fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs_big" >&5
+$as_echo "$boot_jdk_jvmargs_big" >&6; }
+
+  JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command for small workloads" >&5
+$as_echo_n "checking flags for boot jdk java command for small workloads... " >&6; }
+
+  # Use serial gc for small short lived tools if possible
+
+  $ECHO "Check if jvm arg is ok: -XX:+UseSerialGC" >&5
+  $ECHO "Command: $JAVA -XX:+UseSerialGC -version" >&5
+  OUTPUT=`$JAVA -XX:+UseSerialGC -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_small="$boot_jdk_jvmargs_small -XX:+UseSerialGC"
+    JVM_ARG_OK=true
+  else
+    $ECHO "Arg failed:" >&5
+    $ECHO "$OUTPUT" >&5
+    JVM_ARG_OK=false
+  fi
+
+
+  $ECHO "Check if jvm arg is ok: -Xms32M" >&5
+  $ECHO "Command: $JAVA -Xms32M -version" >&5
+  OUTPUT=`$JAVA -Xms32M -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_small="$boot_jdk_jvmargs_small -Xms32M"
+    JVM_ARG_OK=true
+  else
+    $ECHO "Arg failed:" >&5
+    $ECHO "$OUTPUT" >&5
+    JVM_ARG_OK=false
+  fi
+
+
+  $ECHO "Check if jvm arg is ok: -Xmx512M" >&5
+  $ECHO "Command: $JAVA -Xmx512M -version" >&5
+  OUTPUT=`$JAVA -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
+    boot_jdk_jvmargs_small="$boot_jdk_jvmargs_small -Xmx512M"
+    JVM_ARG_OK=true
+  else
+    $ECHO "Arg failed:" >&5
+    $ECHO "$OUTPUT" >&5
+    JVM_ARG_OK=false
+  fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs_small" >&5
+$as_echo "$boot_jdk_jvmargs_small" >&6; }
+
+  JAVA_FLAGS_SMALL=$boot_jdk_jvmargs_small
+
+
+  JAVA_TOOL_FLAGS_SMALL=""
+  for f in $JAVA_FLAGS_SMALL; do
+    JAVA_TOOL_FLAGS_SMALL="$JAVA_TOOL_FLAGS_SMALL -J$f"
+  done
+
+
+
 # Setup smart javac (after cores and memory have been setup)
 
 
@@ -49927,44 +49941,11 @@
       as_fn_error $? "Could not execute server java: $SJAVAC_SERVER_JAVA" "$LINENO" 5
     fi
   else
-    SJAVAC_SERVER_JAVA=""
-    # Hotspot specific options.
-
-  $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.
-
-  $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
-
-
-  if test "$MEMORY_SIZE" -gt "2500"; then
+    SJAVAC_SERVER_JAVA="$JAVA"
+  fi
+
+
+  if test "$MEMORY_SIZE" -gt "3000"; then
 
   $ECHO "Check if jvm arg is ok: -d64" >&5
   $ECHO "Command: $SJAVAC_SERVER_JAVA -d64 -version" >&5
@@ -49986,67 +49967,31 @@
     fi
   fi
 
+  MX_VALUE=`expr $MEMORY_SIZE / 2`
   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"
-    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`
+    # Set ms lower than mx since more than one instance of the server might
+    # get launched at the same time before they figure out which instance won.
+    MS_VALUE=512
+    if test "$MX_VALUE" -gt "2048"; then
+      MX_VALUE=2048
+    fi
+  else
+    MS_VALUE=256
+    if test "$MX_VALUE" -gt "1500"; then
+      MX_VALUE=1500
+    fi
+  fi
+  if test "$MX_VALUE" -lt "512"; then
+    MX_VALUE=512
+  fi
+
+  $ECHO "Check if jvm arg is ok: -Xms${MS_VALUE}M -Xmx${MX_VALUE}M" >&5
+  $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms${MS_VALUE}M -Xmx${MX_VALUE}M -version" >&5
+  OUTPUT=`$SJAVAC_SERVER_JAVA -Xms${MS_VALUE}M -Xmx${MX_VALUE}M -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"
-    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"
-    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"
+    SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms${MS_VALUE}M -Xmx${MX_VALUE}M"
     JVM_ARG_OK=true
   else
     $ECHO "Arg failed:" >&5
@@ -50054,62 +49999,7 @@
     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 -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"
-    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"
-    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; }
+
   # Check whether --enable-sjavac was given.
 if test "${enable_sjavac+set}" = set; then :
   enableval=$enable_sjavac; ENABLE_SJAVAC="${enableval}"
@@ -50117,6 +50007,13 @@
   ENABLE_SJAVAC='no'
 fi
 
+  if test "x$JVM_ARG_OK" = "xfalse"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling sjavac" >&5
+$as_echo "$as_me: WARNING: Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling sjavac" >&2;}
+    ENABLE_SJAVAC=no;
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use sjavac" >&5
+$as_echo_n "checking whether to use sjavac... " >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ENABLE_SJAVAC" >&5
 $as_echo "$ENABLE_SJAVAC" >&6; }
 
--- a/common/bin/hgforest.sh	Fri Aug 29 11:57:22 2014 -0700
+++ b/common/bin/hgforest.sh	Wed Jul 05 19:58:21 2017 +0200
@@ -77,6 +77,11 @@
   shift
 done
 
+# debug mode
+if [ "${HGFOREST_DEBUG:-false}" = "true" ] ; then
+  global_opts="${global_opts} --debug"
+fi
+
 # silence standard output?
 if [ ${qflag} = "true" ] ; then
   global_opts="${global_opts} -q"
@@ -89,14 +94,26 @@
 fi
 
 # Make sure we have a command.
-if [ $# -lt 1 -o -z "${1:-}" ] ; then
-  echo "ERROR: No command to hg supplied!"
-  usage
+if [ ${#} -lt 1 -o -z "${1:-}" ] ; then
+  echo "ERROR: No command to hg supplied!" > ${status_output}
+  usage > ${status_output}
 fi
 
-command="$1"; shift
+# grab command
+command="${1}"; shift
+
+if [ ${vflag} = "true" ] ; then
+  echo "# Mercurial command: ${command}" > ${status_output}
+fi
+
+
+# capture command options and arguments (if any)
 command_args="${@:-}"
 
+if [ ${vflag} = "true" ] ; then
+  echo "# Mercurial command arguments: ${command_args}" > ${status_output}
+fi
+
 # Clean out the temporary directory that stores the pid files.
 tmp=/tmp/forest.$$
 rm -f -r ${tmp}
@@ -104,7 +121,8 @@
 
 
 if [ "${HGFOREST_DEBUG:-false}" = "true" ] ; then
-  echo "DEBUG: temp files are in: ${tmp}"
+  # ignores redirection.
+  echo "DEBUG: temp files are in: ${tmp}" >&2
 fi
 
 # Check if we can use fifos for monitoring sub-process completion.
@@ -377,21 +395,33 @@
       fi
     fi
   done
+
+  if [ ${have_fifos} = "true" ]; then
+    # done with the fifo
+    exec 3>&-
+  fi
 fi
 
 # Wait for all subprocesses to complete
 wait
 
 # Terminate with exit 0 only if all subprocesses were successful
+# Terminate with highest exit code of subprocesses
 ec=0
 if [ -d ${tmp} ]; then
   rcfiles="`(ls -a ${tmp}/*.pid.rc 2> /dev/null) || echo ''`"
   for rc in ${rcfiles} ; do
     exit_code=`cat ${rc} | tr -d ' \n\r'`
     if [ "${exit_code}" != "0" ] ; then
+      if [ ${exit_code} -gt 1 ]; then
+        # mercurial exit codes greater than "1" signal errors.
       repo="`echo ${rc} | sed -e 's@^'${tmp}'@@' -e 's@/*\([^/]*\)\.pid\.rc$@\1@' -e 's@_@/@g'`"
       echo "WARNING: ${repo} exited abnormally (${exit_code})" > ${status_output}
-      ec=1
+      fi
+      if [ ${exit_code} -gt ${ec} ]; then
+        # assume that larger exit codes are more significant
+        ec=${exit_code}
+      fi
     fi
   done
 fi
--- a/get_source.sh	Fri Aug 29 11:57:22 2014 -0700
+++ b/get_source.sh	Wed Jul 05 19:58:21 2017 +0200
@@ -67,7 +67,7 @@
   error "Could not locate Mercurial command"
 fi
 
-hgversion="`hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \([^+]*\).*)\$@\1@p'`"
+hgversion="`LANGUAGE=en hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \([^+]*\).*)\$@\1@p'`"
 if [ "x${hgversion}" = "x" ] ; then
   error "Could not determine Mercurial version of $hgwhere"
 fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/CheckModules.gmk	Wed Jul 05 19:58:21 2017 +0200
@@ -0,0 +1,46 @@
+#
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# Default target declared first
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+
+JDEPS_MODULES_XML := $(JDK_OUTPUTDIR)/modules/jdk.dev/com/sun/tools/jdeps/resources/jdeps-modules.xml
+
+#
+# Verify access across module boundaries
+#
+checkdeps:
+	$(ECHO) "Checking dependencies across JDK modules"
+	$(JAVA) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \
+		-Djdeps.modules.xml=$(JDEPS_MODULES_XML) \
+		com.sun.tools.jdeps.Main \
+		-verify:access -mp $(JDK_OUTPUTDIR)/modules
+
+all: checkdeps
+
+.PHONY: all
--- a/make/CompileJavaModules.gmk	Fri Aug 29 11:57:22 2014 -0700
+++ b/make/CompileJavaModules.gmk	Wed Jul 05 19:58:21 2017 +0200
@@ -28,8 +28,9 @@
 
 include $(SPEC)
 include MakeBase.gmk
+include Modules.gmk
 include JavaCompilation.gmk
-include SetupJava.gmk
+include SetupJavaCompilers.gmk
 
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, , CompileJavaModules.gmk))
@@ -399,36 +400,6 @@
 
 ################################################################################
 
-ifneq ($(OPENJDK_TARGET_OS), solaris)
-  jdk.attach_EXCLUDE_FILES += \
-      sun/tools/attach/SolarisAttachProvider.java \
-      sun/tools/attach/SolarisVirtualMachine.java \
-      #
-endif
-
-ifneq ($(OPENJDK_TARGET_OS), linux)
-  jdk.attach_EXCLUDE_FILES += \
-      sun/tools/attach/LinuxAttachProvider.java \
-      sun/tools/attach/LinuxVirtualMachine.java \
-      #
-endif
-
-ifneq ($(OPENJDK_TARGET_OS), macosx)
-  jdk.attach_EXCLUDE_FILES += \
-      sun/tools/attach/BsdAttachProvider.java \
-      sun/tools/attach/BsdVirtualMachine.java \
-      #
-endif
-
-ifneq ($(OPENJDK_TARGET_OS),aix)
-  jdk.attach_EXCLUDE_FILES += \
-      sun/tools/attach/AixAttachProvider.java \
-      sun/tools/attach/AixVirtualMachine.java \
-      #
-endif
-
-################################################################################
-
 jdk.jvmstat_COPY := aliasmap
 
 ################################################################################
--- a/make/Javadoc.gmk	Fri Aug 29 11:57:22 2014 -0700
+++ b/make/Javadoc.gmk	Wed Jul 05 19:58:21 2017 +0200
@@ -52,7 +52,6 @@
 BUILD_NUMBER=$(JDK_BUILD_NUMBER)
 
 JAVADOC_CMD = $(JAVA) \
-    -Xmx1024m \
     -Djava.awt.headless=true \
     $(NEW_JAVADOC) \
     -bootclasspath $(JDK_OUTPUTDIR)/classes
--- a/make/Main.gmk	Fri Aug 29 11:57:22 2014 -0700
+++ b/make/Main.gmk	Wed Jul 05 19:58:21 2017 +0200
@@ -37,6 +37,7 @@
 
 # Load the vital tools for all the makefiles.
 include $(SRC_ROOT)/make/common/MakeBase.gmk
+include $(SRC_ROOT)/make/common/Modules.gmk
 
 # Load common profile names definitions
 include $(JDK_TOPDIR)/make/ProfileNames.gmk
@@ -234,8 +235,7 @@
 	+($(CD) $(NASHORN_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildNashorn.gmk all)
 
 # Creates the jar files (rt.jar resources.jar etc)
-# this depends on all modules built
-main-jars: exploded-image
+main-jars:
 	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CreateJars.gmk)
 
 # Creates the images (j2sdk-image j2re-image etc)
@@ -297,14 +297,10 @@
 ################################################################################
 # Verification targets
 
-# generate modules.xml in the exploded image
-modules-xml:
-	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f ModulesXml.gmk gen-modules-xml)
+verify-modules:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CheckModules.gmk)
 
-verify-modules:
-	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f ModulesXml.gmk checkdeps)
-
-ALL_TARGETS += modules-xml verify-modules
+ALL_TARGETS += verify-modules
 
 ################################################################################
 # Install targets
@@ -355,6 +351,9 @@
 
   $(LAUNCHER_TARGETS): java.base-libs
 
+  # The demos are currently linking to libjvm and libjava, just like all other
+  # jdk libs, even though they don't need to. To avoid warnings, make sure they
+  # aren't built until after libjava and libjvm are available to link to.
   demos: $(JAVA_TARGETS)
 
   # Declare dependency from <module>-java to <module>-gensrc
@@ -381,16 +380,18 @@
 
   # This dependency needs to be explicitly declared. jdk.jdi-gensrc generates a 
   # header file used by jdk.jdwp libs.
-  jdk.jdwp-libs: jdk.jdi-gensrc
+  jdk.jdwp.agent-libs: jdk.jdi-gensrc
 
   # Explicitly add dependencies for special targets
   java.base-java: unpack-sec
 
+  jdk.dev-gendata: java rmic
+
   security-jars: java
 
   nashorn-jar: jdk.scripting.nashorn-java
 
-  main-jars: java rmic security-jars nashorn-jar policy-jars import-hotspot
+  main-jars: java rmic security-jars nashorn-jar policy-jars import-hotspot gendata
 
   # On windows, the jars target needs to wait for jgss libs to be built.
   # Should ideally split out the sec-bin zip file generation to avoid
@@ -418,9 +419,7 @@
 
   test: exploded-image
 
-  modules-xml: build-tools-jdk java
-
-  verify-modules: exploded-image modules-xml
+  verify-modules: exploded-image
 
 endif
 
@@ -457,7 +456,10 @@
 ALL_MODULE_TARGETS := $(sort $(GENSRC_MODULES) $(JAVA_MODULES) \
     $(GENDATA_MODULES) $(LIB_MODULES) $(LAUNCHER_MODULES) $(COPY_MODULES))
 
-exploded-image: $(ALL_MODULE_TARGETS) modules-xml
+exploded-image: $(ALL_MODULE_TARGETS)
+# The old 'jdk' target most closely matches the new exploded-image. Keep an
+# alias for ease of use.
+jdk: exploded-image
 
 jars: main-jars nashorn-jar security-jars policy-jars
 
@@ -469,7 +471,7 @@
 docs: docs-javadoc docs-jvmtidoc
 
 ALL_TARGETS += gensrc gendata copy java rmic libs launchers \
-    $(ALL_MODULE_TARGETS) exploded-image jars \
+    $(ALL_MODULE_TARGETS) exploded-image jdk jars \
     $(ALL_PROFILES) profiles docs
 
 ################################################################################
@@ -489,6 +491,12 @@
 # If running a clean target, disable parallel execution
 ifneq ($(findstring clean, $(MAKECMDGOALS)), )
   .NOTPARALLEL:
+  # It's not recommended to run additional targets to clean on the same make
+  # command line. Try to detect this and issue a warning.
+  ifneq ($(filter-out clean%, $(MAKECMDGOALS)), )
+    $(warning Mixing clean targets with normal build targets will not work well \
+        and is not recommended.)
+  endif
 endif
 
 CLEAN_COMPONENTS += langtools corba hotspot jdk nashorn images \
--- a/make/MakeHelpers.gmk	Fri Aug 29 11:57:22 2014 -0700
+++ b/make/MakeHelpers.gmk	Wed Jul 05 19:58:21 2017 +0200
@@ -303,4 +303,32 @@
 	@$(PRINTF) " done\n"
 endef
 
+################################################################################
+
+MAKE_DIR_LIST := $(JDK_TOPDIR)/make
+
+# Find all modules that has a makefile for a certain build phase
+# Param 1: Make subdir to look in
+# Param 2: File prefix to look for
+FindModulesWithMakefileFor = $(sort $(foreach d, $(MAKE_DIR_LIST), \
+    $(patsubst $d/$(strip $1)/$(strip $2)-%.gmk,%, \
+    $(wildcard $d/$(strip $1)/$(strip $2)-*.gmk))))
+
+# Declare a recipe for calling such a makefile
+# Param 1: Module name
+# Param 2: Suffix for rule
+# Param 3: Make subdir
+# Param 4: Makefile prefix
+define DeclareRecipeForModuleMakefile
+  $$(strip $1)-$$(strip $2):
+	+($(CD) $$(dir $$(firstword $$(wildcard $$(addsuffix /$$(strip $3)/$$(strip $4)-$$(strip $1).gmk, \
+	        $(MAKE_DIR_LIST))))) \
+	    && $(MAKE) $(MAKE_ARGS) \
+	    -f $$(strip $4)-$$(strip $1).gmk \
+	    $$(addprefix -I, $$(wildcard $(MAKE_DIR_LIST) \
+	        $$(addsuffix /$$(strip $3), $(MAKE_DIR_LIST)))))
+endef
+
+################################################################################
+
 endif # _MAKEHELPERS_GMK
--- a/make/common/IdlCompilation.gmk	Fri Aug 29 11:57:22 2014 -0700
+++ b/make/common/IdlCompilation.gmk	Wed Jul 05 19:58:21 2017 +0200
@@ -60,7 +60,7 @@
 	$(RM) -rf $3/$$($4_TMPDIR)
 	$(MKDIR) -p $(dir $5)
 	$(ECHO) $(LOG_INFO) Compiling IDL $(patsubst $2/%,%,$4)
-	LC_ALL=C $8 -td $3/$$($4_TMPDIR) \
+	$8 -td $3/$$($4_TMPDIR) \
 	    -i $2/org/omg/CORBA \
 	    -i $2/org/omg/PortableInterceptor \
 	    -i $2/org/omg/PortableServer \
--- a/make/common/JavaCompilation.gmk	Fri Aug 29 11:57:22 2014 -0700
+++ b/make/common/JavaCompilation.gmk	Wed Jul 05 19:58:21 2017 +0200
@@ -564,7 +564,7 @@
     endif
 
     # Using sjavac to compile.
-    $1_COMPILE_TARGETS := $$($1_BIN)/javac_state
+    $1_COMPILE_TARGETS := $$($1_BIN)/_the.$1_batch
 
     # Create SJAVAC variable form JAVAC variable. Expects $1_JAVAC to be
     # "bootclasspathprepend -cp .../javac.jar com.sun.tools.javac.Main"
@@ -574,8 +574,12 @@
     # Set the $1_REMOTE to spawn a background javac server.
     $1_REMOTE:=--server:portfile=$$($1_SJAVAC_PORTFILE),id=$1,sjavac=$$(subst $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_SJAVAC))))
 
-    $$($1_BIN)/javac_state: $$($1_SRCS) $$($1_DEPENDS)
+    $$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS)
 	$(MKDIR) -p $$(@D)
+        # As a workaround for sjavac not tracking api changed from the classpath, force full
+        # recompile if an external dependency, which is something other than a source
+        # change, triggered this compilation.
+	$$(if $$(filter-out $$($1_SRCS), $$?), $(FIND) $$(@D) -name "*.class" $(FIND_DELETE))
 	$$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.$1_batch.tmp)
 	$(ECHO) Compiling $1
 	($$($1_JVM) $$($1_SJAVAC) \
@@ -590,8 +594,16 @@
 	    $$($1_HEADERS_ARG) \
 	    -d $$($1_BIN) && \
 	$(MV) $$($1_BIN)/_the.$1_batch.tmp $$($1_BIN)/_the.$1_batch)
-        # sjavac doesn't touch this if nothing has changed
-	$(TOUCH) $$@
+        # Create a pubapi file that only changes when the pubapi changes. Dependent
+        # compilations can use this file to only get recompiled when pubapi has changed.
+        # Grep returns 1 if no matching lines are found. Do not fail for this.
+	$(GREP) -e "^I" $$($1_BIN)/javac_state > $$($1_BIN)/_the.$1_pubapi.tmp \
+	    || test "$$$$?" = "1"
+	if [ ! -f $$($1_BIN)/_the.$1_pubapi ] \
+	    || [ "`$(DIFF) $$($1_BIN)/_the.$1_pubapi $$($1_BIN)/_the.$1_pubapi.tmp`" != "" ]; then \
+	  $(MV) $$($1_BIN)/_the.$1_pubapi.tmp $$($1_BIN)/_the.$1_pubapi; \
+	fi
+
   else
     # Using plain javac to batch compile everything.
     $1_COMPILE_TARGETS := $$($1_BIN)/_the.$1_batch
@@ -681,7 +693,7 @@
 # param 1 is for example BUILD_MYPACKAGE
 # param 2 is the output directory (BIN)
 define SetupJavaCompilationCompileTarget
-  $(if $(findsring yes, $(ENABLE_SJAVAC)), $(strip $2)/javac_state, \
+  $(if $(findstring yes, $(ENABLE_SJAVAC)), $(strip $2)/_the.$(strip $1)_pubapi, \
       $(strip $2)/_the.$(strip $1)_batch)
 endef
 endif
--- a/make/common/MakeBase.gmk	Fri Aug 29 11:57:22 2014 -0700
+++ b/make/common/MakeBase.gmk	Wed Jul 05 19:58:21 2017 +0200
@@ -25,7 +25,6 @@
 
 ################################################################
 #
-# Check that GNU make and cygwin are recent enough.
 # Setup common utility functions.
 #
 ################################################################
@@ -533,71 +532,6 @@
 endef
 
 ################################################################################
-# Module list macros
-
-ALL_TOP_SRC_DIRS := \
-    $(JDK_TOPDIR)/src \
-    $(LANGTOOLS_TOPDIR)/src \
-    $(CORBA_TOPDIR)/src \
-    $(JAXP_TOPDIR)/src \
-    $(JAXWS_TOPDIR)/src \
-    $(NASHORN_TOPDIR)/src \
-    #
-
-# There are snmp classes in the open but they are not included in OpenJDK
-JAVA_MODULES_FILTER := jdk.snmp
-
-# Find all modules with java sources by looking in the source dirs
-define FindJavaModules
-  $(filter-out $(JAVA_MODULES_FILTER), $(sort $(notdir \
-      $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir \
-      $(wildcard $(patsubst %,%/*/share/classes/*, $(ALL_TOP_SRC_DIRS)) \
-          $(patsubst %,%/*/$(OPENJDK_TARGET_OS_API_DIR)/classes/*, $(ALL_TOP_SRC_DIRS)) \
-          $(patsubst %,%/*/$(OPENJDK_TARGET_OS)/classes/*, $(ALL_TOP_SRC_DIRS))))))))))))
-endef
-
-MODULES_LIST_FILE := $(SRC_ROOT)/make/common/modules.list
-
-# Param 1: Module to find deps for
-define FindDepsForModule
-  $(if $(filter-out java.base, $1), java.base $(filter-out jdk.scripting.nashorn, $(filter-out java.base, $(wordlist 2, 100, $(shell $(GREP) '^$(strip $1):' $(MODULES_LIST_FILE))))))
-endef
-
-# Find all modules with source for the target platform.
-define FindAllModules
-  $(sort $(filter-out closed demo sample, $(notdir $(patsubst %/,%, $(dir \
-      $(wildcard $(patsubst %, %/*/share, $(ALL_TOP_SRC_DIRS)) \
-      $(patsubst %, %/*/$(OPENJDK_TARGET_OS), $(ALL_TOP_SRC_DIRS)) \
-      $(patsubst %, %/*/$(OPENJDK_TARGET_OS_API_DIR), $(ALL_TOP_SRC_DIRS))))))))
-endef
-
-################################################################################
-
-MAKE_DIR_LIST := $(JDK_TOPDIR)/make
-
-# Find all modules that has a makefile for a certain build phase
-# Param 1: Make subdir to look in
-# Param 2: File prefix to look for
-FindModulesWithMakefileFor = $(sort $(foreach d, $(MAKE_DIR_LIST), \
-    $(patsubst $d/$(strip $1)/$(strip $2)-%.gmk,%, \
-    $(wildcard $d/$(strip $1)/$(strip $2)-*.gmk))))
-
-# Declare a recipe for calling such a makefile
-# Param 1: Module name
-# Param 2: Suffix for rule
-# Param 3: Make subdir
-# Param 4: Makefile prefix
-define DeclareRecipeForModuleMakefile
-  $$(strip $1)-$$(strip $2):
-	+($(CD) $$(dir $$(firstword $$(wildcard $$(addsuffix /$$(strip $3)/$$(strip $4)-$$(strip $1).gmk, \
-	        $(MAKE_DIR_LIST))))) \
-	    && $(MAKE) $(MAKE_ARGS) \
-	    -f $$(strip $4)-$$(strip $1).gmk \
-	    $$(addprefix -I, $$(wildcard $(MAKE_DIR_LIST) \
-	        $$(addsuffix /$$(strip $3), $(MAKE_DIR_LIST)))))
-endef
-
-################################################################################
 
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, , common/MakeBase.gmk))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/common/Modules.gmk	Wed Jul 05 19:58:21 2017 +0200
@@ -0,0 +1,79 @@
+#
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+ifndef _MODULES_GMK
+_MODULES_GMK := 1
+
+################################################################################
+# Module list macros
+
+ALL_TOP_SRC_DIRS := \
+    $(JDK_TOPDIR)/src \
+    $(LANGTOOLS_TOPDIR)/src \
+    $(CORBA_TOPDIR)/src \
+    $(JAXP_TOPDIR)/src \
+    $(JAXWS_TOPDIR)/src \
+    $(NASHORN_TOPDIR)/src \
+    #
+
+# There are snmp classes in the open but they are not included in OpenJDK
+JAVA_MODULES_FILTER := jdk.snmp
+
+# Find all modules with java sources by looking in the source dirs
+define FindJavaModules
+  $(filter-out $(JAVA_MODULES_FILTER), $(sort $(notdir \
+      $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir \
+      $(wildcard $(patsubst %,%/*/share/classes/*, $(ALL_TOP_SRC_DIRS)) \
+          $(patsubst %,%/*/$(OPENJDK_TARGET_OS_API_DIR)/classes/*, $(ALL_TOP_SRC_DIRS)) \
+          $(patsubst %,%/*/$(OPENJDK_TARGET_OS)/classes/*, $(ALL_TOP_SRC_DIRS))))))))))))
+endef
+
+MODULES_LIST_FILE := $(SRC_ROOT)/make/common/modules.list
+MODULE_DEPS_MAKEFILE := $(OUTPUT_ROOT)/module-deps.gmk
+
+$(MODULE_DEPS_MAKEFILE): $(MODULES_LIST_FILE)
+	$(CAT) $^ | $(SED) -e 's/^\([^:]*\):/DEPS_\1 :=/g' > $@
+
+-include $(MODULE_DEPS_MAKEFILE)
+
+# Param 1: Module to find deps for
+define FindDepsForModule
+  $(DEPS_$(strip $1))
+endef
+
+# Find all modules with source for the target platform.
+define FindAllModules
+  $(sort $(filter-out closed demo sample, $(notdir $(patsubst %/,%, $(dir \
+      $(wildcard $(patsubst %, %/*/share, $(ALL_TOP_SRC_DIRS)) \
+      $(patsubst %, %/*/$(OPENJDK_TARGET_OS), $(ALL_TOP_SRC_DIRS)) \
+      $(patsubst %, %/*/$(OPENJDK_TARGET_OS_API_DIR), $(ALL_TOP_SRC_DIRS))))))))
+endef
+
+################################################################################
+
+# Hook to include the corresponding custom file, if present.
+$(eval $(call IncludeCustomExtension, , common/Modules.gmk))
+
+endif # _MODULES_GMK
--- a/make/common/SetupJava.gmk	Fri Aug 29 11:57:22 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-ifndef _SETUP_GMK
-_SETUP_GMK := 1
-
-include JavaCompilation.gmk
-
-DISABLE_WARNINGS := -Xlint:all,-deprecation,-unchecked,-rawtypes,-cast,-serial,-dep-ann,-static,-fallthrough,-try,-varargs,-empty,-finally
-
-# To build with all warnings enabled, do the following:
-# make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000"
-JAVAC_WARNINGS := -Xlint:all,-deprecation -Werror
-
-# Any java code executed during a JDK build to build other parts of the JDK must be 
-# executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this 
-# purpose must be built with -target PREVIOUS for bootstrapping purposes, which 
-# requires restricting to language level and api of previous JDK.
-#
-# The generate old bytecode javac setup uses the new compiler to compile for the
-# boot jdk to generate tools that need to be run with the boot jdk.
-# Thus we force the target bytecode to the previous JDK version.
-$(eval $(call SetupJavaCompiler,GENERATE_OLDBYTECODE, \
-    JVM := $(JAVA_SMALL), \
-    JAVAC := $(NEW_JAVAC), \
-    FLAGS := $(BOOT_JDK_SOURCETARGET) -bootclasspath $(BOOT_RTJAR) $(DISABLE_WARNINGS), \
-    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
-    SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
-
-# The generate new bytecode javac setup uses the new compiler to compile for the
-# new jdk. This new bytecode might only be possible to run using the new jvm.
-$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
-    JVM := $(JAVA), \
-    JAVAC := $(NEW_JAVAC), \
-    FLAGS := -source 9 -target 9 \
-        -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS) \
-        $(GENERATE_JDKBYTECODE_EXTRA_FLAGS), \
-    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
-    SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
-
-# The generate new bytecode javac setup uses the new compiler to compile for the
-# new jdk. This new bytecode might only be possible to run using the new jvm.
-$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \
-    JVM := $(JAVA), \
-    JAVAC := $(NEW_JAVAC), \
-    FLAGS := -source 9 -target 9 \
-        -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS) \
-        $(GENERATE_JDKBYTECODE_EXTRA_FLAGS), \
-    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
-    SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
-
-JDK_BOOTCLASSPATH := $(subst $(SPACE),$(PATH_SEP),\
-    $(filter-out $(JDK_OUTPUTDIR)/modules/_%, $(wildcard $(JDK_OUTPUTDIR)/modules/*)))
-
-# After the jdk is built, we want to build demos using only the recently
-# generated jdk classes and nothing else, no jdk source, etc etc.
-# I.e. the rt.jar, but since rt.jar has not yet been generated
-# (it will be in "make images") therefore we use classes instead.
-$(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE, \
-    JVM := $(JAVA_SMALL), \
-    JAVAC := $(NEW_JAVAC), \
-    FLAGS := -bootclasspath "$(JDK_BOOTCLASSPATH)" $(DISABLE_WARNINGS), \
-    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
-    SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
-
-endif # _SETUP_GMK
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/common/SetupJavaCompilers.gmk	Wed Jul 05 19:58:21 2017 +0200
@@ -0,0 +1,88 @@
+#
+# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+ifndef _SETUP_GMK
+_SETUP_GMK := 1
+
+include JavaCompilation.gmk
+
+DISABLE_WARNINGS := -Xlint:all,-deprecation,-unchecked,-rawtypes,-cast,-serial,-dep-ann,-static,-fallthrough,-try,-varargs,-empty,-finally
+
+# To build with all warnings enabled, do the following:
+# make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000"
+JAVAC_WARNINGS := -Xlint:all,-deprecation -Werror
+
+# Any java code executed during a JDK build to build other parts of the JDK must be 
+# executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this 
+# purpose must be built with -target PREVIOUS for bootstrapping purposes, which 
+# requires restricting to language level and api of previous JDK.
+#
+# The generate old bytecode javac setup uses the new compiler to compile for the
+# boot jdk to generate tools that need to be run with the boot jdk.
+# Thus we force the target bytecode to the previous JDK version.
+$(eval $(call SetupJavaCompiler,GENERATE_OLDBYTECODE, \
+    JVM := $(JAVA_SMALL), \
+    JAVAC := $(NEW_JAVAC), \
+    FLAGS := $(BOOT_JDK_SOURCETARGET) -bootclasspath $(BOOT_RTJAR) $(DISABLE_WARNINGS), \
+    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
+    SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
+
+# The generate new bytecode javac setup uses the new compiler to compile for the
+# new jdk. This new bytecode might only be possible to run using the new jvm.
+$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
+    JVM := $(JAVA), \
+    JAVAC := $(NEW_JAVAC), \
+    FLAGS := -source 9 -target 9 \
+        -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS) \
+        $(GENERATE_JDKBYTECODE_EXTRA_FLAGS), \
+    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
+    SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
+
+# The generate new bytecode javac setup uses the new compiler to compile for the
+# new jdk. This new bytecode might only be possible to run using the new jvm.
+$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \
+    JVM := $(JAVA), \
+    JAVAC := $(NEW_JAVAC), \
+    FLAGS := -source 9 -target 9 \
+        -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS) \
+        $(GENERATE_JDKBYTECODE_EXTRA_FLAGS), \
+    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
+    SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
+
+JDK_BOOTCLASSPATH := $(subst $(SPACE),$(PATH_SEP),\
+    $(filter-out $(JDK_OUTPUTDIR)/modules/_%, $(wildcard $(JDK_OUTPUTDIR)/modules/*)))
+
+# After the jdk is built, we want to build demos using only the recently
+# generated jdk classes and nothing else, no jdk source, etc etc.
+# I.e. the rt.jar, but since rt.jar has not yet been generated
+# (it will be in "make images") therefore we use classes instead.
+$(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE, \
+    JVM := $(JAVA_SMALL), \
+    JAVAC := $(NEW_JAVAC), \
+    FLAGS := -bootclasspath "$(JDK_BOOTCLASSPATH)" $(DISABLE_WARNINGS), \
+    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
+    SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
+
+endif # _SETUP_GMK
--- a/make/jprt.properties	Fri Aug 29 11:57:22 2014 -0700
+++ b/make/jprt.properties	Wed Jul 05 19:58:21 2017 +0200
@@ -466,15 +466,16 @@
   windows_i586_6.1-fastdebug-c2-hotspot_internalvmtests,		\
   windows_x64_6.1-fastdebug-c2-hotspot_internalvmtests
 
-my.make.rule.test.targets.hotspot.reg.group=					\
-  solaris_sparcv9_5.11-{product|fastdebug}-c2-GROUP,				\
-  solaris_x64_5.11-{product|fastdebug}-c2-GROUP,				\
-  linux_i586_2.6-{product|fastdebug}-c2-GROUP,					\
-  linux_x64_2.6-{product|fastdebug}-c2-GROUP,					\
-  windows_i586_6.1-{product|fastdebug}-c2-GROUP,				\
-  windows_x64_6.1-{product|fastdebug}-c2-GROUP,					\
-  linux_i586_2.6-{product|fastdebug}-c1-GROUP,					\
-  windows_i586_6.1-{product|fastdebug}-c1-GROUP
+my.make.rule.test.targets.hotspot.reg.group=				\
+  solaris_sparcv9_5.11-fastdebug-c2-GROUP,				\
+  solaris_x64_5.11-fastdebug-c2-GROUP,					\
+  linux_i586_2.6-fastdebug-c2-GROUP,					\
+  linux_x64_2.6-fastdebug-c2-GROUP,					\
+  macosx_x64_10.7-fastdebug-c2-GROUP,					\
+  windows_i586_6.1-fastdebug-c2-GROUP,					\
+  windows_x64_6.1-fastdebug-c2-GROUP,					\
+  linux_i586_2.6-fastdebug-c1-GROUP,					\
+  windows_i586_6.1-fastdebug-c1-GROUP
 
 my.make.rule.test.targets.hotspot=						\
   ${my.make.rule.test.targets.hotspot.clienttests},				\
@@ -483,6 +484,7 @@
   ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_wbapitest},	\
   ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_compiler},	\
   ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_gc},		\
-  ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_runtime},	\
+  ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_runtime},		\
+  ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_runtime_closed},	\
   ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_serviceability},	\
   ${my.additional.make.rule.test.targets.hotspot}