1 # Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
  2 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  3 #
  4 # This code is free software; you can redistribute it and/or modify it
  5 # under the terms of the GNU General Public License version 2 only, as
  6 # published by the Free Software Foundation.
  7 #
  8 # This code is distributed in the hope that it will be useful, but WITHOUT
  9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 10 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 11 # version 2 for more details (a copy is included in the LICENSE file that
 12 # accompanied this code).
 13 #
 14 # You should have received a copy of the GNU General Public License version
 15 # 2 along with this work; if not, write to the Free Software Foundation,
 16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 17 #
 18 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 19 # or visit www.oracle.com if you need additional information or have any
 20 # questions.
 21 
 22 #===============================================================================
 23 # HOWTO
 24 #===============================================================================
 25 
 26 # Build the app from source code
 27 #    make app
 28 #
 29 # Run with all Leyden optimizations (new workflow)
 30 #    make run
 31 #    make runn
 32 #
 33 # Run with all CDS static archive only (with Leyden repo)
 34 #    make runs
 35 #
 36 # Run without Leyden optimizations (with Leyden repo)
 37 #    make run0
 38 #
 39 
 40 #===============================================================================
 41 # Environment Config
 42 #===============================================================================
 43 
 44 # The best way to set the paths to various JDKs is to use environment variables to
 45 # set the values for the following variables. E.g.
 46 #  export BLDJDK_HOME=/home/$USER/jdk21
 47 #  export MAINLINE_HOME=/home/$USER/repo/jdk/build/linux-x64/images/jdk
 48 #  export PREMAIN_HOME=/home/$USER/leyden/jdk/build/linux-x64/images/jdk
 49 #  make run
 50 
 51 #  *** NOTE: JDK 21 is needed to build most of the demos
 52 ifndef BLDJDK_HOME
 53 BLDJDK_HOME   = /jdk3/official/jdk21
 54 endif
 55 
 56 # Points to your build with https://github.com/openjdk/jdk
 57 # For comparison purposes, this build should be the latest version of the mainline that
 58 # has been merged into https://github.com/openjdk/leyden/tree/premain
 59 ifndef MAINLINE_HOME
 60 MAINLINE_HOME = /jdk3/bld/rum/images/jdk
 61 endif
 62 
 63 # Points to your build with https://github.com/openjdk/leyden/tree/premain
 64 ifndef PREMAIN_HOME
 65 PREMAIN_HOME = /jdk3/bld/le4/images/jdk
 66 endif
 67 
 68 # Override this if your system's MVM version is too old (to point to your own build of mvn, etc)
 69 ifndef MVN
 70 MVN = mvn
 71 endif
 72 
 73 #===============================================================================
 74 # Common Makefile rules for Leyden demos
 75 #===============================================================================
 76 
 77 # Options passed to PREMAIN_JAVA. See compare_premain_builds in ./Bench.gmk
 78 PM_OPTS =
 79 
 80 JAR             = ${BLDJDK_HOME}/bin/jar
 81 BLDJDK_JAVA     = ${BLDJDK_HOME}/bin/java
 82 MAINLINE_JAVA   = ${MAINLINE_HOME}/bin/java
 83 PREMAIN_JAVA    = ${PREMAIN_HOME}/bin/java ${PM_OPTS}
 84 
 85 # The following variables should be defined by the main Makefile.
 86 # See ../helidon-quickstart-se/Makefile for an example.
 87 
 88 DEMO_CLASSLIST  = ${DEMO_NAME}$(PM_VER).classlist
 89 DEMO_JSA        = ${DEMO_NAME}$(PM_VER).jsa
 90 DEMO_CDS        = ${DEMO_NAME}$(PM_VER).cds
 91 
 92 DEMO_ML_CLASSLIST = ${DEMO_NAME}$(PM_VER).ml.classlist
 93 DEMO_ML_JSA       = ${DEMO_NAME}$(PM_VER).ml.jsa
 94 
 95 # Rules for the following targets should be specified in the main Makefile.
 96 # See ../helidon-quickstart-se/Makefile for an example.
 97 
 98 src: ${DEMO_SRC}
 99 app: ${DEMO_JAR}
100 artifact: ${DEMO_ARTIFACT}
101 
102 #
103 # The following rules should be common to all demos
104 #
105 
106 # Run with the build JDK------------------------
107 runb: ${DEMO_JAR}
108 	${BLDJDK_JAVA} ${DEMO_CMDLINE}
109 
110 # No optimizations (Leyden repo)----------------
111 run0: ${DEMO_JAR}
112 	${PREMAIN_JAVA} ${DEMO_CMDLINE}
113 
114 # Static CDS only (Leyden repo)-----------------
115 
116 list:  ${DEMO_CLASSLIST}
117 jsa:   ${DEMO_JSA}
118 
119 ${DEMO_CLASSLIST}: ${DEMO_JAR}
120 	${PREMAIN_JAVA} -Xshare:off -XX:DumpLoadedClassList=${DEMO_CLASSLIST} ${DEMO_CMDLINE}
121 
122 ${DEMO_JSA}: ${DEMO_CLASSLIST}
123 	rm -f ${DEMO_JSA}.log
124 	${PREMAIN_JAVA} -Xshare:dump -XX:SharedClassListFile=${DEMO_CLASSLIST} -XX:SharedArchiveFile=${DEMO_JSA} \
125 	    -XX:+PreloadSharedClasses \
126 	    -Xlog:cds=debug,cds+class=debug,cds+heap=warning,cds+resolve=debug:file=${DEMO_JSA}.log \
127 	    ${DEMO_CMDLINE}
128 
129 runs:  ${DEMO_JSA}
130 	${PREMAIN_JAVA} -XX:SharedArchiveFile=${DEMO_JSA} ${DEMO_CMDLINE}
131 
132 # Static CDS only (Leyden repo)-----------------
133 
134 list.ml:  ${DEMO_ML_CLASSLIST}
135 jsa.ml:   ${DEMO_ML_JSA}
136 
137 ${DEMO_ML_CLASSLIST}: ${DEMO_JAR}
138 	${MAINLINE_JAVA} -Xshare:off -XX:DumpLoadedClassList=${DEMO_ML_CLASSLIST} ${DEMO_CMDLINE}
139 
140 ${DEMO_ML_JSA}: ${DEMO_ML_CLASSLIST}
141 	rm -f ${DEMO_ML_JSA}.log
142 	${MAINLINE_JAVA} -Xshare:dump -XX:SharedClassListFile=${DEMO_ML_CLASSLIST} -XX:SharedArchiveFile=${DEMO_ML_JSA} \
143 	    -Xlog:cds=debug,cds+class=debug,cds+heap=warning,cds+resolve=debug:file=${DEMO_ML_JSA}.log \
144 	    ${DEMO_CMDLINE}
145 
146 run0.ml: ${DEMO_JAR}
147 	${MAINLINE_JAVA} ${DEMO_CMDLINE}
148 
149 runs.ml: ${DEMO_ML_JSA}
150 	${MAINLINE_JAVA} -XX:SharedArchiveFile=${DEMO_ML_JSA} ${DEMO_CMDLINE}
151 
152 # Leyden new workflow --------------------------
153 
154 cds: ${DEMO_CDS}
155 
156 ${DEMO_CDS}: ${DEMO_JAR}
157 	rm -f ${DEMO_CDS} ${DEMO_CDS}.log
158 	${PREMAIN_JAVA} \
159 	    -XX:CacheDataStore=${DEMO_CDS} -XX:CachedCodeMaxSize=512M \
160 	    -Xlog:scc,cds=debug,cds+class=debug,cds+heap=warning,cds+resolve=debug:file=${DEMO_CDS}.log::filesize=0 \
161 	     ${DEMO_CMDLINE}
162 	ls -l ${DEMO_CDS}
163 	ls -l ${DEMO_CDS}.code
164 
165 run: runn
166 
167 runn: ${DEMO_CDS}
168 	${PREMAIN_JAVA} \
169 	    -XX:CacheDataStore=${DEMO_CDS} \
170 	    -Xlog:scc*=error \
171 	     ${DEMO_CMDLINE}
172 
173 showenv:
174 	@echo "BLDJDK_JAVA   = ${BLDJDK_JAVA}"
175 	@echo "MAINLINE_JAVA = ${MAINLINE_JAVA}"
176 	@echo "PREMAIN_JAVA  = ${PREMAIN_JAVA}"
177 
178 
179 include ../lib/Bench.gmk