Skip to content

Commit e9fe5dd

Browse files
authored
Merge pull request ibmruntimes#933 from keithc-ca/ddr_jpp
Allow use of conditional code in DDR tools
2 parents 35b9b61 + 659caae commit e9fe5dd

File tree

3 files changed

+74
-43
lines changed

3 files changed

+74
-43
lines changed

Diff for: closed/DDR.gmk

+60-39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ===========================================================================
2-
# (c) Copyright IBM Corp. 2018, 2022 All Rights Reserved
2+
# (c) Copyright IBM Corp. 2018, 2025 All Rights Reserved
33
# ===========================================================================
44
# This code is free software; you can redistribute it and/or modify it
55
# under the terms of the GNU General Public License version 2 only, as
@@ -24,8 +24,8 @@
2424
# * compile tools
2525
# * generate java pointer source files
2626
# * generate java structure stub source files
27-
# * generate pointer and structure stub class files
2827
# - compile_check
28+
# * generate pointer and structure stub class files
2929
# * compile DDR_VM source with the generated class files from above
3030
# ===========================================================================
3131

@@ -41,8 +41,9 @@ include $(SPEC)
4141
include $(TOPDIR)/make/common/MakeBase.gmk
4242
include $(TOPDIR)/make/common/JavaCompilation.gmk
4343

44-
# The main source directory.
45-
DDR_VM_SRC_ROOT := $(OPENJ9_TOPDIR)/debugtools/DDR_VM/src
44+
# The main source directories.
45+
DDR_VM_SRC_ROOT_BOOT := $(J9JCL_SOURCES_DIR)/ddr/interim
46+
DDR_VM_SRC_ROOT_NEW := $(J9JCL_SOURCES_DIR)/openj9.dtfj/share/classes
4647

4748
# The top-level directory for intermediate artifacts.
4849
DDR_SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/ddr
@@ -54,7 +55,8 @@ DDR_SUPERSET_FILE := $(OUTPUTDIR)/vm/superset.dat
5455
# Where to write class files.
5556
DDR_CLASSES_BIN := $(DDR_SUPPORT_DIR)/classes
5657
DDR_TEST_BIN := $(DDR_SUPPORT_DIR)/test
57-
DDR_TOOLS_BIN := $(DDR_SUPPORT_DIR)/tools
58+
DDR_TOOLS_BIN_BOOT := $(DDR_SUPPORT_DIR)/tools-interim
59+
DDR_TOOLS_BIN_NEW := $(DDR_SUPPORT_DIR)/tools
5860

5961
# Where to write generated source files.
6062
DDR_GENSRC_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/openj9.dtfj
@@ -64,34 +66,48 @@ DDR_CLASSES_MARKER := $(DDR_SUPPORT_DIR)/classes.done
6466
DDR_POINTERS_MARKER := $(DDR_SUPPORT_DIR)/gensrc-pointers.done
6567
DDR_STRUCTURES_MARKER := $(DDR_SUPPORT_DIR)/gensrc-structures.done
6668

69+
# The list of source files that must be compiled
70+
# (for either the source or class generation steps).
71+
DDR_TOOLS_SOURCE_FILES := \
72+
com/ibm/j9ddr/BytecodeGenerator.java \
73+
com/ibm/j9ddr/CTypeParser.java \
74+
com/ibm/j9ddr/StructureHeader.java \
75+
com/ibm/j9ddr/StructureReader.java \
76+
com/ibm/j9ddr/StructureTypeManager.java \
77+
com/ibm/j9ddr/logging/LoggerNames.java \
78+
com/ibm/j9ddr/tools/ClassGenerator.java \
79+
com/ibm/j9ddr/tools/FlagStructureList.java \
80+
com/ibm/j9ddr/tools/PointerGenerator.java \
81+
com/ibm/j9ddr/tools/StructureStubGenerator.java \
82+
com/ibm/j9ddr/tools/store/J9DDRStructureStore.java \
83+
com/ibm/j9ddr/tools/store/StructureKey.java \
84+
com/ibm/j9ddr/tools/store/StructureMismatchError.java \
85+
#
86+
6787
#############################################################################
6888

69-
# Build the tools we will need.
70-
$(eval $(call SetupJavaCompilation,BUILD_DDR_TOOLS, \
89+
# Build the tools for use with the boot JDK.
90+
$(eval $(call SetupJavaCompilation,BUILD_DDR_TOOLS_BOOT, \
7191
TARGET_RELEASE := $(TARGET_RELEASE_BOOTJDK), \
72-
BIN := $(DDR_TOOLS_BIN), \
92+
BIN := $(DDR_TOOLS_BIN_BOOT), \
7393
CLASSPATH := $(JDK_OUTPUTDIR)/modules/java.base, \
7494
JAVAC_FLAGS := --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED, \
75-
SRC := $(DDR_VM_SRC_ROOT), \
76-
INCLUDE_FILES := \
77-
com/ibm/j9ddr/BytecodeGenerator.java \
78-
com/ibm/j9ddr/CTypeParser.java \
79-
com/ibm/j9ddr/StructureHeader.java \
80-
com/ibm/j9ddr/StructureReader.java \
81-
com/ibm/j9ddr/StructureTypeManager.java \
82-
com/ibm/j9ddr/logging/LoggerNames.java \
83-
com/ibm/j9ddr/tools/ClassGenerator.java \
84-
com/ibm/j9ddr/tools/FlagStructureList.java \
85-
com/ibm/j9ddr/tools/PointerGenerator.java \
86-
com/ibm/j9ddr/tools/StructureStubGenerator.java \
87-
com/ibm/j9ddr/tools/store/J9DDRStructureStore.java \
88-
com/ibm/j9ddr/tools/store/StructureKey.java \
89-
com/ibm/j9ddr/tools/store/StructureMismatchError.java \
95+
SRC := $(DDR_SUPPORT_DIR)/interim, \
96+
INCLUDE_FILES := $(DDR_TOOLS_SOURCE_FILES), \
97+
))
98+
99+
# Build the tools for use with the new JDK.
100+
$(eval $(call SetupJavaCompilation,BUILD_DDR_TOOLS_NEW, \
101+
TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \
102+
BIN := $(DDR_TOOLS_BIN_NEW), \
103+
CLASSPATH := $(JDK_OUTPUTDIR)/modules/java.base, \
104+
SRC := $(DDR_VM_SRC_ROOT_NEW), \
105+
INCLUDE_FILES := $(DDR_TOOLS_SOURCE_FILES), \
90106
))
91107

92108
# Any new references to constants must be paired with additions to the compatibility
93109
# list unless those constants were defined long ago.
94-
DDR_COMPATIBILITY_FILE := $(DDR_VM_SRC_ROOT)/com/ibm/j9ddr/CompatibilityConstants29.dat
110+
DDR_COMPATIBILITY_FILE := $(DDR_VM_SRC_ROOT_NEW)/com/ibm/j9ddr/CompatibilityConstants29.dat
95111

96112
#############################################################################
97113

@@ -101,28 +117,33 @@ DDR_COMPATIBILITY_FILE := $(DDR_VM_SRC_ROOT)/com/ibm/j9ddr/CompatibilityConstant
101117
# might be included: Patching openj9.dtfj fixes that. We use FixPath because
102118
# fixpath.sh would only fix the first entry of the path.
103119
DDR_PATH_SEP := $(if $(filter $(OPENJDK_BUILD_OS),windows),;,:)
104-
DDR_TOOLS_PATHLIST := "$(call FixPath,$(DDR_TOOLS_BIN))$(DDR_PATH_SEP)$(call FixPath,$(DDR_VM_SRC_ROOT))"
105-
DDR_TOOLS_OPTIONS := \
106-
-cp $(DDR_TOOLS_PATHLIST) \
107-
--patch-module=openj9.dtfj=$(DDR_TOOLS_PATHLIST)
120+
121+
DDR_TOOLS_PATHLIST_BOOT := "$(call FixPath,$(DDR_TOOLS_BIN_BOOT))$(DDR_PATH_SEP)$(call FixPath,$(DDR_VM_SRC_ROOT_BOOT))"
122+
DDR_TOOLS_OPTIONS_BOOT := \
123+
-cp $(DDR_TOOLS_PATHLIST_BOOT) \
124+
--patch-module=openj9.dtfj=$(DDR_TOOLS_PATHLIST_BOOT)
125+
126+
DDR_TOOLS_PATHLIST_NEW := "$(call FixPath,$(DDR_TOOLS_BIN_NEW))$(DDR_PATH_SEP)$(call FixPath,$(DDR_VM_SRC_ROOT_NEW))"
127+
DDR_TOOLS_OPTIONS_NEW := \
128+
-cp $(DDR_TOOLS_PATHLIST_NEW) \
129+
--patch-module=openj9.dtfj=$(DDR_TOOLS_PATHLIST_NEW)
108130

109131
# Only fields listed in this file can be directly accessed by hand-written DDR code;
110132
# its contents influence the generated class files.
111-
DDR_FIELDS_FILE := $(DDR_VM_SRC_ROOT)/com/ibm/j9ddr/AuxFieldInfo29.dat
133+
DDR_FIELDS_FILE := $(DDR_VM_SRC_ROOT_NEW)/com/ibm/j9ddr/AuxFieldInfo29.dat
112134

113-
$(DDR_CLASSES_MARKER) : $(DDR_BLOB_FILE) $(DDR_COMPATIBILITY_FILE) $(DDR_FIELDS_FILE) $(BUILD_DDR_TOOLS)
135+
$(DDR_CLASSES_MARKER) : $(DDR_BLOB_FILE) $(DDR_COMPATIBILITY_FILE) $(DDR_FIELDS_FILE) $(BUILD_DDR_TOOLS_NEW)
114136
@$(ECHO) Generating DDR pointer and structure class files
115137
@$(RM) -rf $(DDR_CLASSES_BIN)
116-
@$(JAVA) $(DDR_TOOLS_OPTIONS) \
117-
--add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
138+
@$(JDK_OUTPUTDIR)/bin/java $(DDR_TOOLS_OPTIONS_NEW) \
118139
com.ibm.j9ddr.tools.ClassGenerator \
119140
--blob=$(DDR_BLOB_FILE) \
120141
--out=$(DDR_CLASSES_BIN)
121142
@$(TOUCH) $@
122143

123-
$(DDR_POINTERS_MARKER) : $(DDR_SUPERSET_FILE) $(DDR_FIELDS_FILE) $(BUILD_DDR_TOOLS)
144+
$(DDR_POINTERS_MARKER) : $(DDR_SUPERSET_FILE) $(DDR_FIELDS_FILE) $(BUILD_DDR_TOOLS_BOOT)
124145
@$(ECHO) Generating DDR pointer class source files
125-
@$(JAVA) $(DDR_TOOLS_OPTIONS) com.ibm.j9ddr.tools.PointerGenerator \
146+
@$(JAVA) $(DDR_TOOLS_OPTIONS_BOOT) com.ibm.j9ddr.tools.PointerGenerator \
126147
-a $(DDR_FIELDS_FILE) \
127148
-f $(dir $(DDR_SUPERSET_FILE)) \
128149
-s $(notdir $(DDR_SUPERSET_FILE)) \
@@ -133,9 +154,9 @@ $(DDR_POINTERS_MARKER) : $(DDR_SUPERSET_FILE) $(DDR_FIELDS_FILE) $(BUILD_DDR_TOO
133154

134155
DDR_RESTRICT_FILE := $(OPENJ9_TOPDIR)/debugtools/DDR_VM/data/superset-constants.dat
135156

136-
$(DDR_STRUCTURES_MARKER) : $(DDR_SUPERSET_FILE) $(DDR_RESTRICT_FILE) $(DDR_COMPATIBILITY_FILE) $(DDR_FIELDS_FILE) $(BUILD_DDR_TOOLS)
157+
$(DDR_STRUCTURES_MARKER) : $(DDR_SUPERSET_FILE) $(DDR_RESTRICT_FILE) $(DDR_COMPATIBILITY_FILE) $(DDR_FIELDS_FILE) $(BUILD_DDR_TOOLS_BOOT)
137158
@$(ECHO) Generating DDR structure stub source files
138-
@$(JAVA) $(DDR_TOOLS_OPTIONS) com.ibm.j9ddr.tools.StructureStubGenerator \
159+
@$(JAVA) $(DDR_TOOLS_OPTIONS_BOOT) com.ibm.j9ddr.tools.StructureStubGenerator \
139160
-f $(dir $(DDR_SUPERSET_FILE)) \
140161
-s $(notdir $(DDR_SUPERSET_FILE)) \
141162
-p com.ibm.j9ddr.vm29.structure \
@@ -150,9 +171,9 @@ $(DDR_STRUCTURES_MARKER) : $(DDR_SUPERSET_FILE) $(DDR_RESTRICT_FILE) $(DDR_COMPA
150171
# or StructureStubGenerator) has already done so:
151172
# /usr/bin/cp: cannot create directory 'support/gensrc/openj9.dtfj/com/ibm/j9ddr/vm29': File exists
152173
# To avoid that problem, we insist that $(CP) runs before the other tasks.
153-
$(DDR_POINTERS_MARKER) $(DDR_STRUCTURES_MARKER) : $(call FindFiles,$(DDR_VM_SRC_ROOT))
174+
$(DDR_POINTERS_MARKER) $(DDR_STRUCTURES_MARKER) : $(call FindFiles, $(DDR_VM_SRC_ROOT_NEW))
154175

155-
generate : $(DDR_CLASSES_MARKER) $(DDR_POINTERS_MARKER) $(DDR_STRUCTURES_MARKER)
176+
generate : $(DDR_POINTERS_MARKER) $(DDR_STRUCTURES_MARKER)
156177

157178
#############################################################################
158179

@@ -171,7 +192,7 @@ $(eval $(call SetupJavaCompilation,BUILD_J9DDR_TEST_CLASSES, \
171192
--system none, \
172193
BIN := $(DDR_TEST_BIN), \
173194
CLASSPATH := $(DDR_CLASSES_BIN), \
174-
SRC := $(J9JCL_SOURCES_DIR)/openj9.dtfj/share/classes \
195+
SRC := $(DDR_VM_SRC_ROOT_NEW) \
175196
))
176197

177198
.PHONY : compile_check

Diff for: closed/GensrcJ9JCL.gmk

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ===========================================================================
2-
# (c) Copyright IBM Corp. 2020, 2024 All Rights Reserved
2+
# (c) Copyright IBM Corp. 2020, 2025 All Rights Reserved
33
# ===========================================================================
44
# This code is free software; you can redistribute it and/or modify it
55
# under the terms of the GNU General Public License version 2 only, as
@@ -72,6 +72,11 @@ $(eval $(call SetupCopyFiles,COPY_OVERLAY_FILES, \
7272

7373
IncludeIfUnsure := -includeIfUnsure -noWarnIncludeIf
7474

75+
# OLDEST_BOOT_JDK is not available directly, but it can be extracted
76+
# from BOOT_JDK_SOURCETARGET which has a value like:
77+
# -source $OLDEST_BOOT_JDK -target $OLDEST_BOOT_JDK -Xlint:-options
78+
BOOT_JDK_VERSION := $(word 2, $(BOOT_JDK_SOURCETARGET))
79+
7580
$(J9JCL_SOURCES_DONEFILE) : \
7681
$(foreach dir, $(JppSourceDirs), $(call RecursiveWildcard,$(dir),*)) \
7782
$(COPY_OVERLAY_FILES)
@@ -88,7 +93,12 @@ $(J9JCL_SOURCES_DONEFILE) : \
8893
$(call RunJPP, JAVA$(VERSION_FEATURE), $(OPENJ9_TOPDIR)/jcl, /j9jcl)
8994
ifeq (true,$(OPENJ9_ENABLE_DDR))
9095
@$(ECHO) Generating DDR_VM sources
91-
$(call RunJPP, GENERIC, $(OPENJ9_TOPDIR)/debugtools/DDR_VM/src, /j9jcl/openj9.dtfj/share/classes, $(IncludeIfUnsure) -macro:define JAVA_SPEC_VERSION=$(VERSION_FEATURE))
96+
$(call RunJPP, GENERIC, $(OPENJ9_TOPDIR)/debugtools/DDR_VM/src, /j9jcl/openj9.dtfj/share/classes, \
97+
$(IncludeIfUnsure) -macro:define JAVA_SPEC_VERSION=$(VERSION_FEATURE))
98+
# Also generate source that can be used with the boot JDK.
99+
@$(ECHO) Generating DDR_VM interim sources
100+
$(call RunJPP, GENERIC, $(OPENJ9_TOPDIR)/debugtools/DDR_VM/src, /ddr/interim, \
101+
$(IncludeIfUnsure) -macro:define JAVA_SPEC_VERSION=$(BOOT_JDK_VERSION))
92102
endif # OPENJ9_ENABLE_DDR
93103
@$(MKDIR) -p $(@D)
94104
@$(TOUCH) $@

Diff for: closed/custom/Main.gmk

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ===========================================================================
2-
# (c) Copyright IBM Corp. 2017, 2023 All Rights Reserved
2+
# (c) Copyright IBM Corp. 2017, 2025 All Rights Reserved
33
# ===========================================================================
44
# This code is free software; you can redistribute it and/or modify it
55
# under the terms of the GNU General Public License version 2 only, as
@@ -91,7 +91,7 @@ ifeq (true,$(OPENJ9_ENABLE_DDR))
9191

9292
openj9.dtfj-gensrc-src : j9vm-build
9393

94-
openj9.dtfj-compile_check : openj9.dtfj-java
94+
openj9.dtfj-compile_check : exploded-image
9595
+$(MAKE) $(MAKE_ARGS) -f $(TOPDIR)/closed/DDR.gmk compile_check
9696

9797
openj9.dtfj-jmod : openj9.dtfj-compile_check

0 commit comments

Comments
 (0)