merge JEP-230-microbenchmarks-branch
authorredestad
Fri, 28 Sep 2018 15:32:29 +0200
branchJEP-230-microbenchmarks-branch
changeset 56909 7cf3051d8572
parent 56908 9b57d786b58d (current diff)
parent 56907 040e5da15709 (diff)
child 56911 913e7f339280
child 56913 013359fdfeb2
merge
--- a/make/BuildMicrobenchmark.gmk	Fri Sep 28 15:31:25 2018 +0200
+++ b/make/BuildMicrobenchmark.gmk	Fri Sep 28 15:32:29 2018 +0200
@@ -31,85 +31,80 @@
 include JavaCompilation.gmk
 include SetupJavaCompilers.gmk
 
-# Hook to include the corresponding custom Makefile, if present.
-$(eval $(call IncludeCustomExtension, benchmark, BuildMicrobenchmark.gmk))
+ifeq ($(JMH_CORE_JAR), )
+  $(info Error: JMH is missing. Please use configure --with-jmh.)
+  $(error Cannot continue)
+endif
 
 #### Variables
 
 MICROBENCHMARK_SRC := $(TOPDIR)/test/micro/src/classes
-MICROBENCHMARK_OUTPUT := $(OUTPUTDIR)/micro
-MICROBENCHMARK_DIST := $(OUTPUTDIR)/micro/dist
+MICROBENCHMARK_JAR := $(IMAGES_OUTPUTDIR)/test/micro/microbenchmarks.jar
+
+MICROBENCHMARK_OUTPUT := $(SUPPORT_OUTPUTDIR)/test/micro
+MICROBENCHMARK_CLASSES := $(MICROBENCHMARK_OUTPUT)/classes
+
+JMH_UNPACKED_DIR := $(MICROBENCHMARK_OUTPUT)/jmh_jars
+JMH_UNPACKED_JARS_DONE := $(JMH_UNPACKED_DIR)/_unpacked.marker
 
-# Uncomment MICROBENCHMARK_RESOURCES when resources are added
-#MICROBENCHMARK_RESOURCES += $(TOPDIR)/test/micro/src/resources
-MICROBENCHMARK_CLASSES := $(OUTPUTDIR)/micro/classes
-MICROBENCHMARK_GENERATED_SRC := $(MICROBENCHMARK_CLASSES)_generated
-MICROBENCHMARK_JAR := $(MICROBENCHMARK_DIST)/benchmarks.jar
+# External dependencies
+JMH_COMPILE_JARS := $(JMH_CORE_JAR) $(JMH_GENERATOR_JAR)
+JMH_RUNTIME_JARS := $(JMH_CORE_JAR) $(JMH_COMMONS_MATH_JAR) $(JMH_JOPT_SIMPLE_JAR)
+
+MICROBENCHMARK_CLASSPATH := $(call PathList, $(JMH_COMPILE_JARS))
 
-JMH_UNPACKED := $(MICROBENCHMARK_OUTPUT)/jmh_unpacked
+###
+
+# Need double \n to get new lines and no trailing spaces
+MICROBENCHMARK_MANIFEST := Build: $(FULL_VERSION)\n\
+\nJMH-Version: $(JMH_VERSION)\n\
+\nName: OpenJDK Microbenchmark Suite
+
 
 #### Compile Targets
 
-# Create separate directories for generated files 
-# Avoids copying .java files into JARs later
-$(MICROBENCHMARK_GENERATED_SRC)/_generated.state:
-	$(RM) -r $(MICROBENCHMARK_GENERATED_SRC)
-	$(MKDIR) -p $(MICROBENCHMARK_GENERATED_SRC)
-	$(TOUCH) $@
-
-$(call PrintVar, JMH_COMPILE_JARS)
-$(call PrintVar, JMH_RUNTIME_JARS)
-
-ENABLE_JAVAC_SERVER := false
-
-# Building microbenchmark requires the jdk.unsupported and java.management modules
-$(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE_UNSUPPORTED, \
+# Building microbenchmark requires the jdk.unsupported and java.management modules,
+# and to have sjavac disabled.
+$(eval $(call SetupJavaCompiler, MICROBENCHMARK_JAVA_COMPILER, \
     JVM := $(JAVA_SMALL) --add-modules jdk.unsupported --limit-modules java.management, \
     JAVAC := $(NEW_JAVAC), \
+    DISABLE_SJAVAC := true, \
     FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none $(DISABLE_WARNINGS), \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
-    SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
+    SERVER_JVM := $(SJAVAC_SERVER_JAVA), \
+))
 
 # Build microbenchmark suite for the current JDK
-$(eval $(call SetupJavaCompilation,BUILD_JDK_MICROBENCHMARK, \
-    SETUP := GENERATE_USINGJDKBYTECODE_UNSUPPORTED, \
-    DISABLE_SJAVAC := true, \
-    ADD_JAVAC_FLAGS := -cp $(call PathList, $(JMH_COMPILE_JARS)) \
-        -s $(MICROBENCHMARK_GENERATED_SRC) \
-        -Xlint -Werror, \
+$(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \
+    SETUP := MICROBENCHMARK_JAVA_COMPILER, \
+    ADD_JAVAC_FLAGS := -cp $(MICROBENCHMARK_CLASSPATH) -Xlint -Werror, \
     SRC := $(MICROBENCHMARK_SRC), \
-    BIN := $(MICROBENCHMARK_CLASSES)))
+    BIN := $(MICROBENCHMARK_CLASSES), \
+))
 
-$(BUILD_JDK_MICROBENCHMARK): $(JMH_COMPILE_JARS) $(MICROBENCHMARK_GENERATED_SRC)/_generated.state
-
-#### Package Targets
+$(BUILD_JDK_MICROBENCHMARK): $(JMH_COMPILE_JARS)
 
 # Unpacking dependencies for inclusion in the benchmark JARs
-$(JMH_UNPACKED)/_unpacked.state: $(JMH_RUNTIME_JARS)
-	$(RM) -r $(JMH_UNPACKED)
-	$(MKDIR) -p $(JMH_UNPACKED)
+$(JMH_UNPACKED_JARS_DONE): $(JMH_RUNTIME_JARS)
+	$(RM) -r $(JMH_UNPACKED_DIR)
+	$(MKDIR) -p $(JMH_UNPACKED_DIR)
 	$(foreach jar, $(JMH_RUNTIME_JARS), \
-            $$($(UNZIP) -oq $(jar) -d $(JMH_UNPACKED)))
-	$(RM) -r $(JMH_UNPACKED)/META-INF
-	$(RM) $(JMH_UNPACKED)/*.xml
+            $$($(UNZIP) -oq $(jar) -d $(JMH_UNPACKED_DIR)))
+	$(RM) -r $(JMH_UNPACKED_DIR)/META-INF
+	$(RM) $(JMH_UNPACKED_DIR)/*.xml
 	$(TOUCH) $@
 
-# Need double \n to get new lines and no trailing spaces
-MANIFEST_ATTRIBUTES := Build: $(FULL_VERSION)\n\
-\nJMH-Version: $(JMH_VERSION)\n\
-\nName: OpenJDK Microbenchmark Suite
-
 # Create benchmarks JAR file with benchmarks for both the old and new JDK
-$(eval $(call SetupJarArchive,BUILD_JDK_JAR, \
-    DEPENDENCIES := $(BUILD_JDK_MICROBENCHMARK) \
-        $(JMH_UNPACKED)/_unpacked.state, \
-    SRCS := $(JMH_UNPACKED) $(MICROBENCHMARK_CLASSES) $(MICROBENCHMARK_RESOURCES), \
+$(eval $(call SetupJarArchive, BUILD_JDK_JAR, \
+    DEPENDENCIES := $(BUILD_JDK_MICROBENCHMARK) $(JMH_UNPACKED_JARS_DONE), \
+    SRCS := $(MICROBENCHMARK_CLASSES) $(JMH_UNPACKED_DIR) , \
     SUFFIXES := .*, \
     EXCLUDE_FILES:= _the.BUILD_JDK_MICROBENCHMARK_batch \
-        _the.BUILD_JDK_MICROBENCHMARK.vardeps _unpacked.state, \
-    EXTRA_MANIFEST_ATTR := $(MANIFEST_ATTRIBUTES), \
+        _the.BUILD_JDK_MICROBENCHMARK.vardeps _unpacked.marker, \
+    EXTRA_MANIFEST_ATTR := $(MICROBENCHMARK_MANIFEST), \
     JARMAIN := org.openjdk.jmh.Main, \
-    JAR := $(MICROBENCHMARK_JAR)))
+    JAR := $(MICROBENCHMARK_JAR), \
+))
 
 all: $(MICROBENCHMARK_JAR)
 
--- a/make/Main.gmk	Fri Sep 28 15:31:25 2018 +0200
+++ b/make/Main.gmk	Fri Sep 28 15:32:29 2018 +0200
@@ -1020,6 +1020,10 @@
     test-image-jdk-jtreg-native test-image-failure-handler \
     test-image-demos-jdk $(JVM_TEST_IMAGE_TARGETS)
 
+ifneq ($(JMH_CORE_JAR), )
+  test-image: build-microbenchmark
+endif
+
 ################################################################################
 
 # all-images builds all our deliverables as images.
--- a/make/autoconf/lib-tests.m4	Fri Sep 28 15:31:25 2018 +0200
+++ b/make/autoconf/lib-tests.m4	Fri Sep 28 15:32:29 2018 +0200
@@ -64,68 +64,56 @@
   AC_ARG_WITH(jmh, [AS_HELP_STRING([--with-jmh],
       [Java Microbenchmark Harness for building the OpenJDK Microbenchmark Suite])])
 
-  # JMH configuration parameters
-  JMH_VERSION=1.21
-
-  # JAR files below must be listed on a single line as a comma separated 
-  # list without any spaces. The version number unfortunately needs to be 
-  # written out as this file is read by both configure and make which use 
-  # different variable expansion syntax.
-
-  # JARs required for compiling microbenchmarks
-  JMH_COMPILE_JAR_NAMES="jmh-generator-annprocess-1.21.jar jmh-core-1.21.jar"
-  JMH_COMPILE_JARS=""
-
-  # JARs required for running microbenchmarks
-  JMH_RUNTIME_JAR_NAMES="commons-math3-3.2.jar jopt-simple-4.6.jar jmh-core-1.21.jar"
-  JMH_RUNTIME_JARS=""
-
+  AC_MSG_CHECKING([for jmh (Java Microbenchmark Harness)])
   if test "x$with_jmh" = xno || test "x$with_jmh" = x; then
-    AC_MSG_CHECKING([for jmh])
-    AC_MSG_RESULT(no)
+    AC_MSG_RESULT([no, disabled])
   elif test "x$with_jmh" = xyes; then
-    AC_MSG_ERROR([Must specify a directory containing JMH and required JAR files or a subdirectory named with JMH version])
+    AC_MSG_RESULT([no, error])
+    AC_MSG_ERROR([--with-jmh-home requires a directory containing all jars needed by JMH])
   else
     # Path specified
-    AC_MSG_CHECKING([for jmh])
-
-
     JMH_HOME="$with_jmh"
-
+    if test ! -d [$JMH_HOME]; then
+      AC_MSG_RESULT([no, error])
+      AC_MSG_ERROR([$JMH_HOME does not exist or is not a directory])
+    fi
     BASIC_FIXUP_PATH([JMH_HOME])
 
-    # Check that JMH directory exist
-    if test ! -d [$JMH_HOME]; then
-      AC_MSG_ERROR([$JMH_HOME does not exist or is not a directory])
-    fi
+    jar_names="jmh-core jmh-generator-annprocess jopt-simple commons-math3"
+    for jar in $jar_names; do
+      found_jar_files=$($ECHO $(ls $JMH_HOME/$jar-*.jar 2> /dev/null))
+
+      if test "x$found_jar_files" = x; then
+        AC_MSG_RESULT([no])
+        AC_MSG_ERROR([--with-jmh does not contain $jar-*.jar])
+      elif ! test -e "$found_jar_files"; then
+        AC_MSG_RESULT([no])
+        AC_MSG_ERROR([--with-jmh contain multiple $jar-*.jar: $found_jar_files])
+      fi
 
-    # Check and use version specific JMH directory
-    if test -d [$JMH_HOME/$JMH_VERSION]; then
-      JMH_HOME="$JMH_HOME/$JMH_VERSION"
+      found_jar_var_name=found_${jar//-/_}
+      eval $found_jar_var_name='"'$found_jar_files'"'
+    done
+    AC_MSG_RESULT([yes])
+
+    JMH_CORE_JAR=$found_jmh_core
+    JMH_GENERATOR_JAR=$found_jmh_generator_annprocess
+    JMH_JOPT_SIMPLE_JAR=$found_jopt_simple
+    JMH_COMMONS_MATH_JAR=$found_commons_math3
+
+
+    if [ [[ "$JMH_CORE_JAR" =~ jmh-core-(.*)\.jar$ ]] ] ; then
+      JMH_VERSION=${BASH_REMATCH[[1]]}
+    else
+      JMH_VERSION=unknown
     fi
 
-    # Check that required files exist in the JMH directory
-    for jar in $JMH_COMPILE_JAR_NAMES; do
-      if test ! -f [$JMH_HOME/$jar]; then
-        AC_MSG_ERROR([$JMH_HOME does not contain $jar])
-      fi
-      JMH_COMPILE_JARS="$JMH_COMPILE_JARS $JMH_HOME/$jar"
-    done
-    
-    for jar in $JMH_RUNTIME_JAR_NAMES; do
-      if test ! -f [$JMH_HOME/$jar]; then
-        AC_MSG_ERROR([$JMH_HOME does not contain $jar])
-      fi
-      JMH_RUNTIME_JARS="$JMH_RUNTIME_JARS $JMH_HOME/$jar"
-    done
-
-
-    AC_MSG_RESULT([yes, Version: $JMH_VERSION, Location: $JMH_HOME ($JMH_COMPILE_JARS / $JMH_RUNTIME_JARS)])
+    AC_MSG_NOTICE([JMH core version: $JMH_VERSION])
   fi
 
-  AC_SUBST(JMH_HOME)
+  AC_SUBST(JMH_CORE_JAR)
+  AC_SUBST(JMH_GENERATOR_JAR)
+  AC_SUBST(JMH_JOPT_SIMPLE_JAR)
+  AC_SUBST(JMH_COMMONS_MATH_JAR)
   AC_SUBST(JMH_VERSION)
-  AC_SUBST(JMH_COMPILE_JARS)
-  AC_SUBST(JMH_RUNTIME_JARS)
 ])
-
--- a/make/autoconf/spec.gmk.in	Fri Sep 28 15:31:25 2018 +0200
+++ b/make/autoconf/spec.gmk.in	Fri Sep 28 15:32:29 2018 +0200
@@ -353,6 +353,12 @@
 LIBFFI_LIB_FILE:=@LIBFFI_LIB_FILE@
 GRAALUNIT_LIB := @GRAALUNIT_LIB@
 
+JMH_CORE_JAR := @JMH_CORE_JAR@
+JMH_GENERATOR_JAR := @JMH_GENERATOR_JAR@
+JMH_JOPT_SIMPLE_JAR := @JMH_JOPT_SIMPLE_JAR@
+JMH_COMMONS_MATH_JAR := @JMH_COMMONS_MATH_JAR@
+JMH_VERSION := @JMH_VERSION@
+
 # Source file for cacerts
 CACERTS_FILE=@CACERTS_FILE@
 
@@ -724,10 +730,6 @@
 JT_HOME:=@JT_HOME@
 JTREGEXE:=@JTREGEXE@
 JIB_HOME:=@JIB_HOME@
-JMH_HOME:=@JMH_HOME@
-JMH_VERSION:=@JMH_VERSION@
-JMH_COMPILE_JARS:=@JMH_COMPILE_JARS@
-JMH_RUNTIME_JARS:=@JMH_RUNTIME_JARS@
 XCODEBUILD=@XCODEBUILD@
 DTRACE := @DTRACE@
 FIXPATH:=@FIXPATH@