2
# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
26
# This must be the first rule
33
include JavaCompilation.gmk
34
include TestFilesCompilation.gmk
36
ifeq ($(JMH_CORE_JAR), )
37
$(info Error: JMH is missing. Please use configure --with-jmh.)
38
$(error Cannot continue)
43
MICROBENCHMARK_SRC := $(TOPDIR)/test/micro
44
MICROBENCHMARK_IMAGE_DIR := $(TEST_IMAGE_DIR)/micro
45
MICROBENCHMARK_JAR := $(MICROBENCHMARK_IMAGE_DIR)/benchmarks.jar
47
MICROBENCHMARK_OUTPUT := $(SUPPORT_OUTPUTDIR)/test/micro
48
MICROBENCHMARK_CLASSES := $(MICROBENCHMARK_OUTPUT)/classes
49
MICROBENCHMARK_JAR_BIN := $(MICROBENCHMARK_OUTPUT)/jar
51
MICROBENCHMARK_TOOLS_CLASSES := $(MICROBENCHMARK_OUTPUT)/tools-classes
52
MICROBENCHMARK_INDIFY_DONE := $(MICROBENCHMARK_CLASSES)/_indify.marker
54
JMH_UNPACKED_DIR := $(MICROBENCHMARK_OUTPUT)/jmh_jars
55
JMH_UNPACKED_JARS_DONE := $(JMH_UNPACKED_DIR)/_unpacked.marker
57
# External dependencies
58
WHITEBOX_JAR := $(SUPPORT_OUTPUTDIR)/test/lib/wb.jar
59
JMH_COMPILE_JARS := $(JMH_CORE_JAR) $(JMH_GENERATOR_JAR) $(WHITEBOX_JAR)
60
JMH_RUNTIME_JARS := $(JMH_CORE_JAR) $(JMH_COMMONS_MATH_JAR) $(JMH_JOPT_SIMPLE_JAR)
63
MICROBENCHMARK_NATIVE_SRC_DIRS := $(MICROBENCHMARK_SRC)
64
MICROBENCHMARK_NATIVE_OUTPUT := $(MICROBENCHMARK_OUTPUT)/native
65
MICROBENCHMARK_NATIVE_EXCLUDE :=
69
# Need double \n to get new lines and no trailing spaces
70
MICROBENCHMARK_MANIFEST := Build: $(FULL_VERSION)\n\
71
\nJMH-Version: $(JMH_VERSION)\n\
72
\nName: OpenJDK Microbenchmark Suite
74
#### Compile Indify tool
76
$(eval $(call SetupJavaCompilation, BUILD_INDIFY, \
77
TARGET_RELEASE := $(TARGET_RELEASE_BOOTJDK), \
78
SRC := $(TOPDIR)/test/jdk/java/lang/invoke, \
79
INCLUDE_FILES := indify/Indify.java, \
80
DISABLED_WARNINGS := this-escape rawtypes serial options, \
81
BIN := $(MICROBENCHMARK_TOOLS_CLASSES), \
82
JAVAC_FLAGS := -XDstringConcat=inline -Xprefer:newer, \
87
# Building microbenchmark requires the jdk.unsupported and java.management modules.
88
# sun.security.util is required to compile Cache benchmark.
89
# jmh uses annotation processors to generate the benchmark jar and thus
90
# requires the use of -processor option during benchmark compilation.
92
# Build microbenchmark suite for the current JDK
93
$(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \
94
TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \
95
SMALL_JAVA := false, \
96
CLASSPATH := $(JMH_COMPILE_JARS), \
97
DISABLED_WARNINGS := restricted this-escape processing rawtypes removal cast \
98
serial preview dangling-doc-comments, \
99
SRC := $(MICROBENCHMARK_SRC), \
100
BIN := $(MICROBENCHMARK_CLASSES), \
102
--add-exports java.base/jdk.internal.classfile.impl=ALL-UNNAMED \
103
--add-exports java.base/jdk.internal.event=ALL-UNNAMED \
104
--add-exports java.base/jdk.internal.foreign=ALL-UNNAMED \
105
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED \
106
--add-exports java.base/jdk.internal.util=ALL-UNNAMED \
107
--add-exports java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED \
108
--add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
109
--add-exports java.base/jdk.internal.vm=ALL-UNNAMED \
110
--add-exports java.base/sun.invoke.util=ALL-UNNAMED \
111
--add-exports java.base/sun.security.util=ALL-UNNAMED \
112
--add-exports java.base/sun.security.util.math=ALL-UNNAMED \
113
--add-exports java.base/sun.security.util.math.intpoly=ALL-UNNAMED \
116
-processor org.openjdk.jmh.generators.BenchmarkProcessor, \
118
--add-exports java.base/jdk.internal.vm=ALL-UNNAMED \
119
--add-modules jdk.unsupported \
121
--limit-modules java.management, \
124
$(BUILD_JDK_MICROBENCHMARK): $(JMH_COMPILE_JARS)
127
$(MICROBENCHMARK_INDIFY_DONE): $(BUILD_INDIFY) $(BUILD_JDK_MICROBENCHMARK)
128
$(call LogWarn, Running Indify on microbenchmark classes)
129
$(JAVA_SMALL) -cp $(MICROBENCHMARK_TOOLS_CLASSES) \
130
indify.Indify --overwrite $(MICROBENCHMARK_CLASSES) \
134
# Unpacking dependencies for inclusion in the benchmark JARs
135
$(JMH_UNPACKED_JARS_DONE): $(JMH_RUNTIME_JARS)
136
$(RM) -r $(JMH_UNPACKED_DIR)
137
$(MKDIR) -p $(JMH_UNPACKED_DIR)
138
$(foreach jar, $(JMH_RUNTIME_JARS), \
139
$$($(UNZIP) -oq $(jar) -d $(JMH_UNPACKED_DIR)))
140
$(RM) -r $(JMH_UNPACKED_DIR)/META-INF
141
$(RM) $(JMH_UNPACKED_DIR)/*.xml
144
# Create benchmarks JAR file with benchmarks for both the old and new JDK
145
$(eval $(call SetupJarArchive, BUILD_JDK_JAR, \
146
DEPENDENCIES := $(BUILD_JDK_MICROBENCHMARK) $(JMH_UNPACKED_JARS_DONE) \
147
$(MICROBENCHMARK_INDIFY_DONE), \
148
SRCS := $(MICROBENCHMARK_CLASSES) $(JMH_UNPACKED_DIR), \
149
BIN := $(MICROBENCHMARK_JAR_BIN), \
151
EXCLUDE_FILES:= _the.BUILD_JDK_MICROBENCHMARK_batch \
152
_the.BUILD_JDK_MICROBENCHMARK.vardeps _unpacked.marker, \
153
EXTRA_MANIFEST_ATTR := $(MICROBENCHMARK_MANIFEST), \
154
JARMAIN := org.openjdk.jmh.Main, \
155
JAR := $(MICROBENCHMARK_JAR), \
158
# Setup compilation of native library dependencies
159
$(eval $(call SetupTestFilesCompilation, BUILD_MICROBENCHMARK_LIBRARIES, \
161
SOURCE_DIRS := $(MICROBENCHMARK_NATIVE_SRC_DIRS), \
162
OUTPUT_DIR := $(MICROBENCHMARK_NATIVE_OUTPUT), \
163
EXCLUDE := $(MICROBENCHMARK_NATIVE_EXCLUDE), \
166
# Setup copy of native dependencies to image output dir
167
$(eval $(call SetupCopyFiles, COPY_MICROBENCHMARK_NATIVE, \
168
SRC := $(MICROBENCHMARK_NATIVE_OUTPUT)/lib, \
169
DEST := $(MICROBENCHMARK_IMAGE_DIR)/native, \
170
FILES := $(filter $(MICROBENCHMARK_NATIVE_OUTPUT)/lib/%, \
171
$(BUILD_MICROBENCHMARK_LIBRARIES)), \
174
all: $(MICROBENCHMARK_JAR) $(BUILD_MICROBENCHMARK_LIBRARIES) $(COPY_MICROBENCHMARK_NATIVE)