1 # Copyright (c) 2023, 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 # This is a new propsed workflow for the "terminal stage" of the Leyden 23 # condenser pipeline (see https://openjdk.org/projects/leyden/notes/03-toward-condensers) 24 # 25 # The CDS and AOT artifacts are generated in a single step. 26 # 27 # Please run this script and look at the commands in the generated cmds.txt file. 28 29 # Usage: 30 # 31 # bash run.sh $JAVA 32 # bash run.sh $JAVA args .... 33 # 34 # e.g. 35 # 36 # bash.sh /jdk3/bld/le4/images/jdk/bin/java 37 # bash.sh /jdk3/bld/le4/images/jdk/bin/java -XX:+UnlockDiagnosticVMOptions -XX:-AOTInvokeDynamicLinking 38 39 # These options are enabled by default for training run. You can either disable them in the command-line 40 # as shown above, or edit the following line 41 # 42 # The training run uses two JVM processes. We add "pid" to the log to distinguish their output. 43 TRAINING_OPTS="${TRAINING_OPTS} -Xlog:scc -Xlog:cds=debug::uptime,tags,pid" 44 TRAINING_OPTS="${TRAINING_OPTS} -XX:+AOTClassLinking" 45 #TRAINING_OPTS="${TRAINING_OPTS} -XX:+RecordTraining" 46 47 # These options are enabled by default for training run. 48 #PRODUCTION_OPTS="${PRODUCTION_OPTS} -XX:+ReplayTraining" 49 50 51 launcher=$1 52 shift 53 54 rm -f cmds.txt 55 #======================================== 56 # One-step training run 57 # Remove javac.cds, so that it will be regenerated 58 rm -f javac.cds* 59 cmd="$launcher -XX:CacheDataStore=javac.cds $TRAINING_OPTS "$@" com.sun.tools.javac.Main HelloWorld.java" 60 61 echo "# commands for training run" >> cmds.txt 62 echo "rm -f javac.cds*" >> cmds.txt 63 echo $cmd >> cmds.txt 64 echo >> cmds.txt 65 eval $cmd 66 67 #======================================== 68 # Production run 69 # TODO: add flags for AOT cache 70 cmd="$launcher $PRODUCTION_OPTS -Xlog:cds -Xlog:scc -XX:CacheDataStore=javac.cds $@ com.sun.tools.javac.Main HelloWorld.java" 71 perfcmd="perf stat -r 20 $(echo $cmd | sed -e 's/ [-]Xlog:[^ ]*//g')" 72 echo "Production run: " 73 echo " $cmd" 74 echo " " 75 76 rm -f HelloWorld.class 77 eval "$cmd" 78 79 echo "# command for production run" >> cmds.txt 80 echo $cmd >> cmds.txt 81 echo >> cmds.txt 82 83 echo "# commands for benchmarking" >> cmds.txt 84 echo perf stat -r 20 $launcher $@ com.sun.tools.javac.Main HelloWorld.java >> cmds.txt 85 echo $perfcmd >> cmds.txt 86 echo >> cmds.txt 87 88 echo "cat cmds.txt" 89 cat cmds.txt 90 91 echo ======================================== 92 echo "Verifying" 93 if (set -x; $launcher -Xshare:off -cp . HelloWorld); then 94 echo javac seems to be working correctly with $PRODUCTION_OPTS -XX:CacheDataStore=javac.cds 95 else 96 echo "Failed?????????????????" 97 exit 1 98 fi 99