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