From 486594d4273e9d5a8db43de861e3ca3ce823f0da Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 11 Dec 2023 14:17:38 +0000 Subject: [PATCH] 8316657: Support whitebox testing in microbenchmarks Reviewed-by: erikj, redestad --- make/Main.gmk | 11 +++++++++-- make/test/BuildMicrobenchmark.gmk | 29 ++++++++++++++++------------- make/test/BuildTestLib.gmk | 29 ++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 18 deletions(-) diff --git a/make/Main.gmk b/make/Main.gmk index e904235ff3f..5534a68f13b 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -744,9 +744,16 @@ endif $(eval $(call SetupTarget, build-test-lib, \ MAKEFILE := test/BuildTestLib, \ + TARGET := build-test-lib, \ DEPS := exploded-image, \ )) +$(eval $(call SetupTarget, test-image-lib, \ + MAKEFILE := test/BuildTestLib, \ + TARGET := test-image-lib, \ + DEPS := build-test-lib, \ +)) + ifeq ($(BUILD_FAILURE_HANDLER), true) # Builds the failure handler jtreg extension $(eval $(call SetupTarget, build-test-failure-handler, \ @@ -781,7 +788,7 @@ endif $(eval $(call SetupTarget, build-microbenchmark, \ MAKEFILE := test/BuildMicrobenchmark, \ - DEPS := interim-langtools exploded-image, \ + DEPS := interim-langtools exploded-image build-test-lib, \ )) ################################################################################ @@ -1264,7 +1271,7 @@ all-docs-bundles: docs-jdk-bundles docs-javase-bundles docs-reference-bundles # This target builds the test image test-image: prepare-test-image test-image-jdk-jtreg-native \ test-image-demos-jdk test-image-libtest-jtreg-native \ - test-image-lib-native + test-image-lib test-image-lib-native ifneq ($(JVM_TEST_IMAGE_TARGETS), ) # If JVM_TEST_IMAGE_TARGETS is externally defined, use it instead of the diff --git a/make/test/BuildMicrobenchmark.gmk b/make/test/BuildMicrobenchmark.gmk index 7660de061d2..628f3855728 100644 --- a/make/test/BuildMicrobenchmark.gmk +++ b/make/test/BuildMicrobenchmark.gmk @@ -53,11 +53,10 @@ JMH_UNPACKED_DIR := $(MICROBENCHMARK_OUTPUT)/jmh_jars JMH_UNPACKED_JARS_DONE := $(JMH_UNPACKED_DIR)/_unpacked.marker # External dependencies -JMH_COMPILE_JARS := $(JMH_CORE_JAR) $(JMH_GENERATOR_JAR) +WHITEBOX_JAR := $(SUPPORT_OUTPUTDIR)/test/lib/wb.jar +JMH_COMPILE_JARS := $(JMH_CORE_JAR) $(JMH_GENERATOR_JAR) $(WHITEBOX_JAR) JMH_RUNTIME_JARS := $(JMH_CORE_JAR) $(JMH_COMMONS_MATH_JAR) $(JMH_JOPT_SIMPLE_JAR) -MICROBENCHMARK_CLASSPATH := $(call PathList, $(JMH_COMPILE_JARS)) - # Native dependencies MICROBENCHMARK_NATIVE_SRC_DIRS := $(MICROBENCHMARK_SRC) MICROBENCHMARK_NATIVE_OUTPUT := $(MICROBENCHMARK_OUTPUT)/native @@ -92,24 +91,28 @@ $(eval $(call SetupJavaCompilation, BUILD_INDIFY, \ $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \ TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \ SMALL_JAVA := false, \ - CLASSPATH := $(MICROBENCHMARK_CLASSPATH), \ - DISABLED_WARNINGS := restricted this-escape processing rawtypes cast serial preview, \ + CLASSPATH := $(JMH_COMPILE_JARS), \ + DISABLED_WARNINGS := restricted this-escape processing rawtypes cast \ + serial preview, \ SRC := $(MICROBENCHMARK_SRC), \ BIN := $(MICROBENCHMARK_CLASSES), \ - JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \ - --add-exports java.base/sun.invoke.util=ALL-UNNAMED \ + JAVAC_FLAGS := \ --add-exports java.base/jdk.internal.classfile.impl=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.vm=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.misc=ALL-UNNAMED \ --add-exports java.base/jdk.internal.event=ALL-UNNAMED \ --add-exports java.base/jdk.internal.foreign=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.vm=ALL-UNNAMED \ + --add-exports java.base/sun.invoke.util=ALL-UNNAMED \ + --add-exports java.base/sun.security.util=ALL-UNNAMED \ --enable-preview \ -processor org.openjdk.jmh.generators.BenchmarkProcessor, \ - JAVA_FLAGS := --add-modules jdk.unsupported --limit-modules java.management \ + JAVA_FLAGS := \ --add-exports java.base/jdk.internal.vm=ALL-UNNAMED \ - --enable-preview, \ + --add-modules jdk.unsupported \ + --enable-preview \ + --limit-modules java.management, \ )) $(BUILD_JDK_MICROBENCHMARK): $(JMH_COMPILE_JARS) diff --git a/make/test/BuildTestLib.gmk b/make/test/BuildTestLib.gmk index 72f777ec6c1..54c4c61642c 100644 --- a/make/test/BuildTestLib.gmk +++ b/make/test/BuildTestLib.gmk @@ -23,12 +23,22 @@ # questions. # +################################################################################ +# This file builds the Java components of testlib. +# It also covers the test-image part, where the built files are copied to the +# test image. +################################################################################ + default: all include $(SPEC) include MakeBase.gmk include JavaCompilation.gmk +################################################################################ +# Targets for building the test lib jars +################################################################################ + TARGETS := TEST_LIB_SOURCE_DIR := $(TOPDIR)/test/lib @@ -63,8 +73,21 @@ $(eval $(call SetupJavaCompilation, BUILD_TEST_LIB_JAR, \ TARGETS += $(BUILD_TEST_LIB_JAR) -########################################################################################## +build-test-lib: $(TARGETS) -all: $(TARGETS) +################################################################################ +# Targets for building test-image. +################################################################################ -.PHONY: default all +# Copy the jars to the test image. +$(eval $(call SetupCopyFiles, COPY_LIBTEST_JARS, \ + DEST := $(TEST_IMAGE_DIR)/lib-test, \ + FILES := $(BUILD_WB_JAR_JAR) $(BUILD_TEST_LIB_JAR_JAR), \ +)) +# + +test-image-lib: $(COPY_LIBTEST_JARS) + +all: build-test-lib + +.PHONY: default all build-test-lib test-image-lib