1 # 2 # Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. Oracle designates this 8 # particular file as subject to the "Classpath" exception as provided 9 # by Oracle in the LICENSE file that accompanied this code. 10 # 11 # This code is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 # version 2 for more details (a copy is included in the LICENSE file that 15 # accompanied this code). 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 include MakeFileStart.gmk 27 28 ################################################################################ 29 30 include CopyFiles.gmk 31 include JarArchive.gmk 32 include JavaCompilation.gmk 33 include TestFilesCompilation.gmk 34 35 ifeq ($(JMH_CORE_JAR), ) 36 $(info Error: JMH is missing. Please use configure --with-jmh.) 37 $(error Cannot continue) 38 endif 39 40 #### Variables 41 42 MICROBENCHMARK_SRC := $(TOPDIR)/test/micro 43 MICROBENCHMARK_IMAGE_DIR := $(TEST_IMAGE_DIR)/micro 44 MICROBENCHMARK_JAR := $(MICROBENCHMARK_IMAGE_DIR)/benchmarks.jar 45 46 MICROBENCHMARK_OUTPUT := $(SUPPORT_OUTPUTDIR)/test/micro 47 MICROBENCHMARK_CLASSES := $(MICROBENCHMARK_OUTPUT)/classes 48 MICROBENCHMARK_GENSRC := $(MICROBENCHMARK_OUTPUT)/gensrc 49 MICROBENCHMARK_JAR_BIN := $(MICROBENCHMARK_OUTPUT)/jar 50 51 MICROBENCHMARK_TOOLS_CLASSES := $(MICROBENCHMARK_OUTPUT)/tools-classes 52 53 JMH_UNPACKED_DIR := $(MICROBENCHMARK_OUTPUT)/jmh_jars 54 JMH_UNPACKED_JARS_DONE := $(JMH_UNPACKED_DIR)/_unpacked.marker 55 56 # External dependencies 57 WHITEBOX_JAR := $(SUPPORT_OUTPUTDIR)/test/lib/wb.jar 58 JMH_COMPILE_JARS := $(JMH_CORE_JAR) $(JMH_GENERATOR_JAR) $(WHITEBOX_JAR) 59 JMH_RUNTIME_JARS := $(JMH_CORE_JAR) $(JMH_COMMONS_MATH_JAR) $(JMH_JOPT_SIMPLE_JAR) 60 61 # Native dependencies 62 MICROBENCHMARK_NATIVE_SRC_DIRS := $(MICROBENCHMARK_SRC) 63 MICROBENCHMARK_NATIVE_OUTPUT := $(MICROBENCHMARK_OUTPUT)/native 64 MICROBENCHMARK_NATIVE_EXCLUDE := 65 66 ### 67 68 # Need double \n to get new lines and no trailing spaces 69 MICROBENCHMARK_MANIFEST := Build: $(FULL_VERSION)\n\ 70 \nJMH-Version: $(JMH_VERSION)\n\ 71 \nName: OpenJDK Microbenchmark Suite 72 73 #### Compile Targets 74 75 # Building microbenchmark requires the jdk.unsupported and java.management modules. 76 # sun.security.util is required to compile Cache benchmark. 77 # jmh uses annotation processors to generate the benchmark jar and thus 78 # requires the use of -processor option during benchmark compilation. 79 80 # Build microbenchmark suite for the current JDK 81 $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \ 82 TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \ 83 SMALL_JAVA := false, \ 84 CLASSPATH := $(JMH_COMPILE_JARS), \ 85 CREATE_API_DIGEST := true, \ 86 DISABLED_WARNINGS := restricted this-escape processing rawtypes removal cast \ 87 serial preview unchecked deprecation dangling-doc-comments, \ 88 SRC := $(MICROBENCHMARK_SRC), \ 89 BIN := $(MICROBENCHMARK_CLASSES), \ 90 JAVAC_FLAGS := \ 91 --add-exports java.base/jdk.internal.classfile.components=ALL-UNNAMED \ 92 --add-exports java.base/jdk.internal.classfile.impl=ALL-UNNAMED \ 93 --add-exports java.base/jdk.internal.event=ALL-UNNAMED \ 94 --add-exports java.base/jdk.internal.foreign=ALL-UNNAMED \ 95 --add-exports java.base/jdk.internal.jimage=ALL-UNNAMED \ 96 --add-exports java.base/jdk.internal.misc=ALL-UNNAMED \ 97 --add-exports java.base/jdk.internal.util=ALL-UNNAMED \ 98 --add-exports java.base/jdk.internal.value=ALL-UNNAMED \ 99 --add-exports java.base/jdk.internal.vm=ALL-UNNAMED \ 100 --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED \ 101 --add-exports java.base/sun.invoke.util=ALL-UNNAMED \ 102 --add-exports java.base/sun.security.util=ALL-UNNAMED \ 103 --add-exports java.base/sun.security.util.math=ALL-UNNAMED \ 104 --add-exports java.base/sun.security.util.math.intpoly=ALL-UNNAMED \ 105 --enable-preview \ 106 -XDsuppressNotes \ 107 -processor org.openjdk.jmh.generators.BenchmarkProcessor \ 108 -s $(MICROBENCHMARK_GENSRC), \ 109 JAVA_FLAGS := \ 110 --add-exports java.base/jdk.internal.vm=ALL-UNNAMED \ 111 --add-modules jdk.unsupported \ 112 --enable-preview \ 113 --limit-modules java.management, \ 114 )) 115 116 $(BUILD_JDK_MICROBENCHMARK): $(JMH_COMPILE_JARS) 117 118 # Unpacking dependencies for inclusion in the benchmark JARs 119 $(JMH_UNPACKED_JARS_DONE): $(JMH_RUNTIME_JARS) 120 $(RM) -r $(JMH_UNPACKED_DIR) 121 $(MKDIR) -p $(JMH_UNPACKED_DIR) 122 $(foreach jar, $(JMH_RUNTIME_JARS), \ 123 $$($(UNZIP) -oq $(jar) -d $(JMH_UNPACKED_DIR))) 124 $(RM) -r $(JMH_UNPACKED_DIR)/META-INF 125 $(TOUCH) $@ 126 127 # Copy dependency files for inclusion in the benchmark JARs 128 $(eval $(call SetupCopyFiles, COPY_JAXP_TEST_XML, \ 129 SRC := $(TOPDIR)/test/jaxp/javax/xml/jaxp/unittest, \ 130 DEST := $(MICROBENCHMARK_CLASSES)/org/openjdk/bench/javax/xml, \ 131 FILES := \ 132 stream/XMLStreamWriterTest/message_12.xml \ 133 validation/tck/reZ003vExc23082309.xml \ 134 transform/msgAttach.xml, \ 135 FLATTEN := true, \ 136 )) 137 138 # Create benchmarks JAR file with benchmarks for both the old and new JDK 139 $(eval $(call SetupJarArchive, BUILD_JDK_JAR, \ 140 DEPENDENCIES := $(BUILD_JDK_MICROBENCHMARK) $(JMH_UNPACKED_JARS_DONE) $(COPY_JAXP_TEST_XML), \ 141 SRCS := $(MICROBENCHMARK_CLASSES) $(JMH_UNPACKED_DIR), \ 142 BIN := $(MICROBENCHMARK_JAR_BIN), \ 143 SUFFIXES := .*, \ 144 EXCLUDE_FILES := _the.BUILD_JDK_MICROBENCHMARK_batch \ 145 _the.BUILD_JDK_MICROBENCHMARK.vardeps _unpacked.marker, \ 146 EXTRA_MANIFEST_ATTR := $(MICROBENCHMARK_MANIFEST), \ 147 JARMAIN := org.openjdk.jmh.Main, \ 148 JAR := $(MICROBENCHMARK_JAR), \ 149 )) 150 151 # Setup compilation of native library dependencies 152 $(eval $(call SetupTestFilesCompilation, BUILD_MICROBENCHMARK_LIBRARIES, \ 153 TYPE := LIBRARY, \ 154 SOURCE_DIRS := $(MICROBENCHMARK_NATIVE_SRC_DIRS), \ 155 OUTPUT_DIR := $(MICROBENCHMARK_NATIVE_OUTPUT), \ 156 EXCLUDE := $(MICROBENCHMARK_NATIVE_EXCLUDE), \ 157 )) 158 159 # Setup copy of native dependencies to image output dir 160 $(eval $(call SetupCopyFiles, COPY_MICROBENCHMARK_NATIVE, \ 161 SRC := $(MICROBENCHMARK_NATIVE_OUTPUT)/lib, \ 162 DEST := $(MICROBENCHMARK_IMAGE_DIR)/native, \ 163 FILES := $(filter $(MICROBENCHMARK_NATIVE_OUTPUT)/lib/%, \ 164 $(BUILD_MICROBENCHMARK_LIBRARIES)), \ 165 )) 166 167 all: $(MICROBENCHMARK_JAR) $(BUILD_MICROBENCHMARK_LIBRARIES) $(COPY_MICROBENCHMARK_NATIVE) 168 169 ################################################################################ 170 171 include MakeFileEnd.gmk