duke@435: #!/bin/sh -x duke@435: # xdono@631: # Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. duke@435: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: # duke@435: # This code is free software; you can redistribute it and/or modify it duke@435: # under the terms of the GNU General Public License version 2 only, as duke@435: # published by the Free Software Foundation. duke@435: # duke@435: # This code is distributed in the hope that it will be useful, but WITHOUT duke@435: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: # version 2 for more details (a copy is included in the LICENSE file that duke@435: # accompanied this code). duke@435: # duke@435: # You should have received a copy of the GNU General Public License version duke@435: # 2 along with this work; if not, write to the Free Software Foundation, duke@435: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: # duke@435: # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: # CA 95054 USA or visit www.sun.com if you need additional information or duke@435: # have any questions. duke@435: # duke@435: # duke@435: duke@435: # Generate the reorder data for hotspot. duke@435: # duke@435: # Usage: duke@435: # duke@435: # sh reorder.sh duke@435: # duke@435: # is a *built* SDK workspace which contains the duke@435: # reordering tools for the SDK. This script relies on lib_mcount.so duke@435: # from this workspace. duke@435: # duke@435: # is a working SDK which you can use to run the profiled duke@435: # JVMs in to collect data. You must be able to write to this SDK. duke@435: # duke@435: # is a directory containing JBB test jar files and properties duke@435: # which will be used to run the JBB test to provide reordering data duke@435: # for the server VM. duke@435: # duke@435: # Profiled builds of the VM are needed (before running this script), duke@435: # build with PROFILE_PRODUCT=1: duke@435: # duke@435: # gnumake profiled1 profiled PROFILE_PRODUCT=1 duke@435: # duke@435: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ duke@435: duke@435: test_setup() { duke@435: duke@435: # $1 = "client" or "server" duke@435: # $2 = name of reorder file to be generated. duke@435: duke@435: echo "" duke@435: echo "TEST_SETUP $1 $2" duke@435: echo "" kamg@526: libreldir=${ALT_OUTPUTDIR:-../../../make/solaris-$arch5}/reorder kamg@526: libabsdir=${ALT_OUTPUTDIR:-$sdk_ws/make/solaris-$arch5}/reorder duke@435: ( cd $sdk_ws/make/tools/reorder ; gnumake $libreldir/$arch5/libmcount.so ) duke@435: if [ "${arch3}" = "i386" ] ; then duke@435: # On Solaris/x86 we need to remove the symbol _mcount from the command duke@435: ( cd $sdk_ws/make/tools/reorder ; \ duke@435: gnumake $libreldir/$arch5/remove_mcount ) duke@435: echo Remove _mcount from java command. duke@435: $libabsdir/$arch5/remove_mcount $jre/bin/java duke@435: fi duke@435: ( cd $sdk_ws/make/tools/reorder ; gnumake tool_classes ) duke@435: ( cd $sdk_ws/make/tools/reorder ; gnumake test_classes ) duke@435: duke@435: tests="Null Exit Hello Sleep IntToString \ duke@435: LoadToolkit LoadFrame LoadJFrame JHello" duke@435: swingset=$sdk/demo/jfc/SwingSet2/SwingSet2.jar duke@435: java=$jre/bin/java duke@435: if [ "X$LP64" != "X" ] ; then duke@435: testjava="$jre/bin/${arch3}/java" duke@435: else duke@435: testjava="$jre/bin/java" duke@435: fi duke@435: mcount=$libabsdir/$arch5/libmcount.so duke@435: duke@435: if [ ! -x $mcount ] ; then duke@435: echo $mcount is missing! duke@435: exit 1 duke@435: fi duke@435: duke@435: if [ "X$1" = "client" ] ; then duke@435: if [ "X$NO_SHARING" = "X" ] ; then duke@435: echo "Dumping shared file." duke@435: LD_PRELOAD=$mcount \ duke@435: JDK_ALTERNATE_VM=jvm_profiled \ duke@435: $testjava -Xshare:dump -Xint -XX:PermSize=16m -version 2> /dev/null duke@435: shared_client="-Xshare:on" duke@435: echo "Shared file dump completed." duke@435: else duke@435: shared_client="-Xshare:off" duke@435: echo "NO_SHARING defined, not using sharing." duke@435: fi duke@435: else duke@435: echo "Server: no sharing" duke@435: shared_server="-Xshare:off" duke@435: fi duke@435: duke@435: testpath=$libabsdir/classes duke@435: duke@435: reorder_file=$2 duke@435: duke@435: rm -f ${reorder_file} duke@435: rm -f ${reorder_file}_tmp2 duke@435: rm -f ${reorder_file}_tmp1 duke@435: duke@435: echo "data = R0x2000;" > ${reorder_file} duke@435: echo "text = LOAD ?RXO;" >> ${reorder_file} duke@435: echo "" >> ${reorder_file} duke@435: echo "" >> ${reorder_file} duke@435: } duke@435: duke@435: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ duke@435: duke@435: test_client() { duke@435: duke@435: # Run each of a set of tests, extract the methods called, duke@435: # append the new functions to the reorder list. duke@435: # $1 = "client" or "server" duke@435: # $2 = name of reorder file to be generated. duke@435: duke@435: echo "TEST_CLIENT $1 $2." duke@435: test_setup $1 $2 duke@435: echo "TEST_CLIENT $1 $2." duke@435: duke@435: for f in $tests ; do duke@435: echo Running test $f. duke@435: rm -f ${reorder_file}_tmp1 duke@435: echo "# Test $f" >> ${reorder_file} duke@435: duke@435: echo "Using LD_PRELOAD=$mcount" duke@435: echo $testjava ${shared_client} -classpath $testpath $f duke@435: duke@435: LD_PRELOAD=$mcount \ duke@435: JDK_ALTERNATE_VM=jvm_profiled \ duke@435: $testjava ${shared_client} -classpath $testpath $f 2> ${reorder_file}_tmp1 duke@435: duke@435: echo "Done." duke@435: sed -n -e '/^text:/p' ${reorder_file}_tmp1 > ${reorder_file}_tmp2 duke@435: sed -e '/^text:/d' ${reorder_file}_tmp1 duke@435: LD_LIBRARY_PATH=$lib/server \ duke@435: $java -classpath $testpath Combine ${reorder_file} \ duke@435: ${reorder_file}_tmp2 \ duke@435: > ${reorder_file}_tmp3 duke@435: mv ${reorder_file}_tmp3 ${reorder_file} duke@435: rm -f ${reorder_file}_tmp2 duke@435: rm -f ${reorder_file}_tmp1 duke@435: done duke@435: duke@435: # Run SwingSet, extract the methods called, duke@435: # append the new functions to the reorder list. duke@435: duke@435: echo "# SwingSet" >> ${reorder_file} duke@435: duke@435: echo "" duke@435: echo "" duke@435: echo "When SwingSet has finished drawing, " \ duke@435: "you may terminate it (with your mouse)." duke@435: echo "Otherwise, it should be automatically terminated in 3 minutes." duke@435: echo "" duke@435: echo "" duke@435: duke@435: echo "Using LD_PRELOAD=$mcount, JDK_ALTERNATE=jvm_profiled." duke@435: echo $testjava ${shared_client} -classpath $testpath MaxTime $swingset 60 duke@435: LD_PRELOAD=$mcount \ duke@435: JDK_ALTERNATE_VM=jvm_profiled \ duke@435: $testjava ${shared_client} -classpath $testpath MaxTime \ duke@435: $swingset 60 2> ${reorder_file}_tmp1 duke@435: duke@435: sed -n -e '/^text:/p' ${reorder_file}_tmp1 > ${reorder_file}_tmp2 duke@435: duke@435: LD_LIBRARY_PATH=$lib/server \ duke@435: $java -server -classpath $testpath Combine ${reorder_file} ${reorder_file}_tmp2 \ duke@435: > ${reorder_file}_tmp3 duke@435: echo mv ${reorder_file}_tmp3 ${reorder_file} duke@435: mv ${reorder_file}_tmp3 ${reorder_file} duke@435: echo rm -f ${reorder_file}_tmp2 duke@435: rm -f ${reorder_file}_tmp2 duke@435: echo rm -f ${reorder_file}_tmp1 duke@435: rm -f ${reorder_file}_tmp1 duke@435: } duke@435: duke@435: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ duke@435: duke@435: test_server() { duke@435: duke@435: # Run the JBB script, collecting data on the way. duke@435: # $1 = "client" or "server" duke@435: # $2 = name of reorder file to be generated. duke@435: duke@435: echo "TEST_SERVER $1 $2." duke@435: test_setup $1 $2 duke@435: echo "TEST_SERVER $1 $2." duke@435: duke@435: echo Running JBB. duke@435: duke@435: rm -f ${reorder_file}_tmp1 duke@435: rm -f ${reorder_file}_tmp2 duke@435: heap=200m duke@435: duke@435: CLASSPATH=jbb.jar:jbb_no_precompile.jar:check.jar:reporter.jar duke@435: duke@435: ( cd $jbb_dir; LD_PRELOAD=$mcount MCOUNT_ORDER_BY_COUNT=1 \ duke@435: JDK_ALTERNATE_VM=jvm_profiled \ duke@435: $testjava ${shared_server} -classpath $CLASSPATH -Xms${heap} -Xmx${heap} \ duke@435: spec.jbb.JBBmain -propfile SPECjbb.props ) 2> ${reorder_file}_tmp1 duke@435: duke@435: sed -n -e '/^text:/p' ${reorder_file}_tmp1 > ${reorder_file}_tmp2 duke@435: sed -e '/^text:/d' ${reorder_file}_tmp1 duke@435: cat ${reorder_file}_tmp2 >> ${reorder_file} duke@435: rm -f ${reorder_file}_tmp2 duke@435: rm -f ${reorder_file}_tmp1 duke@435: } duke@435: duke@435: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ duke@435: duke@435: # Rename the old VMs, copy the new in, run the test, and put the duke@435: # old one back. duke@435: duke@435: copy_and_test() { duke@435: duke@435: # $1 = "client" or "server" duke@435: # $2 = name of reorder file to be generated. duke@435: # $3 = profiled jvm to copy in duke@435: duke@435: echo "COPY_AND_TEST ($1, $2, $3)." duke@435: # $2 = name of reorder file to be generated. duke@435: # $3 = profiled jvm to copy in duke@435: duke@435: rm -rf $lib/jvm_profiled duke@435: mkdir $lib/jvm_profiled duke@435: cp $3 $lib/jvm_profiled duke@435: test_$1 $1 $2 duke@435: rm -rf $lib/jvm_profiled duke@435: } duke@435: duke@435: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ duke@435: duke@435: duke@435: # Check arguments: duke@435: duke@435: if [ $# != 3 ] ; then duke@435: echo "" duke@435: echo "Usage:" duke@435: echo " sh reorder.sh " duke@435: echo "" duke@435: exit 1 duke@435: fi duke@435: duke@435: sdk_ws=$1 duke@435: if [ ! -r $sdk_ws/make/tools/reorder/Makefile ] ; then duke@435: echo "" duke@435: echo "test workspace "$sdk_ws" does not contain the reordering tools." duke@435: echo "" duke@435: exit 1 duke@435: fi duke@435: duke@435: sdk=$2 duke@435: jre=$sdk/jre duke@435: duke@435: # Set up architecture names as needed by various components. duke@435: # Why couldn't we just use x86 for everything? duke@435: duke@435: # Arch name as used in JRE runtime (eg. i386): duke@435: # .../jre/lib/${arch3}/server duke@435: arch3=`uname -p` duke@435: duke@435: # Arch name as used in Hotspot build: (eg. i486) kamg@526: # /export/hotspot/make/solaris/solaris_${arch4}_compiler1 duke@435: arch4=$arch3 duke@435: duke@435: # Arch name as used in SDK build (eg. i586): kamg@526: # /export/tiger/make/solaris-${arch3} duke@435: arch5=$arch3 duke@435: duke@435: # Tweak for 64-bit sparc builds. At least they all agree. duke@435: if [ $arch3 = sparc -a "X$LP64" != "X" ] ; then duke@435: arch3=sparcv9 duke@435: arch4=sparcv9 duke@435: arch5=sparcv9 duke@435: fi duke@435: duke@435: # Tweak for 64-bit i386 == amd64 builds. At least they all agree. duke@435: if [ $arch3 = i386 -a "X$LP64" != "X" ] ; then duke@435: arch3=amd64 duke@435: arch4=amd64 duke@435: arch5=amd64 duke@435: fi duke@435: duke@435: # Tweak for x86 builds. All different. duke@435: if [ $arch3 = i386 ] ; then duke@435: arch4=i486 duke@435: arch5=i586 duke@435: fi duke@435: duke@435: lib=$jre/lib/$arch3 duke@435: if [ ! -r $jre/lib/rt.jar ] ; then duke@435: echo "" duke@435: echo "test SDK "$sdk" is not a suitable SDK." duke@435: echo "" duke@435: exit 1 duke@435: fi duke@435: duke@435: jbb_dir=$3 duke@435: if [ ! -r $jbb_dir/jbb.jar ] ; then duke@435: echo "" duke@435: echo "jbb.jar not present in $jbb_dir" duke@435: echo "" duke@435: exit 1 duke@435: fi duke@435: duke@435: duke@435: # Were profiled VMs built? duke@435: duke@435: if [ "X$LP64" != "X" ] ; then duke@435: if [ ! -r solaris_${arch4}_compiler2/profiled/libjvm.so ] ; then duke@435: echo "" duke@435: echo "Profiled builds of compiler2 are needed first." duke@435: echo ' -- build with "make profiled PROFILE_PRODUCT=1" -- ' duke@435: echo "" duke@435: exit 1 duke@435: fi duke@435: else duke@435: if [ ! -r solaris_${arch4}_compiler1/profiled/libjvm.so \ duke@435: -o ! -r solaris_${arch4}_compiler2/profiled/libjvm.so ] ; then duke@435: echo "" duke@435: echo "Profiled builds of compiler1 and compiler2 are needed first." duke@435: echo ' -- build with "make profiled{,1} PROFILE_PRODUCT=1" -- ' duke@435: exit 1 duke@435: fi duke@435: fi duke@435: duke@435: duke@435: # Compiler1 - not supported in 64-bit (b69 java launcher rejects it). duke@435: duke@435: if [ "X$LP64" = "X" ] ; then duke@435: #gnumake profiled1 duke@435: echo Using profiled client VM. duke@435: echo duke@435: copy_and_test client \ duke@435: reorder_COMPILER1_$arch4 \ duke@435: solaris_${arch4}_compiler1/profiled/libjvm.so duke@435: fi duke@435: duke@435: #gnumake profiled duke@435: echo Using profiled server VM. duke@435: echo duke@435: copy_and_test server \ duke@435: reorder_COMPILER2_$arch4 \ duke@435: solaris_${arch4}_compiler2/profiled/libjvm.so