#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Generate the reorder data for hotspot.
#
# Usage:
#
# sh reorder.sh <test_sdk_workspace> <test_sdk> <jbb_dir>
#
# <test_sdk_workspace> is a *built* SDK workspace which contains the
# reordering tools for the SDK. This script relies on lib_mcount.so
# from this workspace.
#
# <test_sdk> is a working SDK which you can use to run the profiled
# JVMs in to collect data. You must be able to write to this SDK.
#
# <jbb_dir> is a directory containing JBB test jar files and properties
# which will be used to run the JBB test to provide reordering data
# for the server VM.
#
# Profiled builds of the VM are needed (before running this script),
# build with PROFILE_PRODUCT=1:
#
# gnumake profiled1 profiled PROFILE_PRODUCT=1
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# $1 = "client" or "server"
# $2 = name of reorder file to be generated.
echo ""
echo "TEST_SETUP $1 $2"
echo ""
( cd $sdk_ws/make/tools/reorder ; gnumake $libreldir/$arch5/libmcount.so )
if [ "${arch3}" = "i386" ] ; then
fi
tests="Null Exit Hello Sleep IntToString \
LoadToolkit LoadFrame LoadJFrame JHello"
else
fi
if [ ! -x $mcount ] ; then
exit 1
fi
if [ "X$1" = "client" ] ; then
echo "Dumping shared file."
shared_client="-Xshare:on"
echo "Shared file dump completed."
else
shared_client="-Xshare:off"
echo "NO_SHARING defined, not using sharing."
fi
else
echo "Server: no sharing"
shared_server="-Xshare:off"
fi
reorder_file=$2
rm -f ${reorder_file}
rm -f ${reorder_file}_tmp2
rm -f ${reorder_file}_tmp1
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Run each of a set of tests, extract the methods called,
# append the new functions to the reorder list.
# $1 = "client" or "server"
# $2 = name of reorder file to be generated.
echo "TEST_CLIENT $1 $2."
test_setup $1 $2
echo "TEST_CLIENT $1 $2."
echo Running test $f.
rm -f ${reorder_file}_tmp1
echo "Using LD_PRELOAD=$mcount"
echo $testjava ${shared_client} -classpath $testpath $f
$testjava ${shared_client} -classpath $testpath $f 2> ${reorder_file}_tmp1
echo "Done."
${reorder_file}_tmp2 \
> ${reorder_file}_tmp3
mv ${reorder_file}_tmp3 ${reorder_file}
rm -f ${reorder_file}_tmp2
rm -f ${reorder_file}_tmp1
done
# Run SwingSet, extract the methods called,
# append the new functions to the reorder list.
echo ""
echo ""
echo "When SwingSet has finished drawing, " \
"you may terminate it (with your mouse)."
echo "Otherwise, it should be automatically terminated in 3 minutes."
echo ""
echo ""
echo "Using LD_PRELOAD=$mcount, JDK_ALTERNATE=jvm_profiled."
$swingset 60 2> ${reorder_file}_tmp1
> ${reorder_file}_tmp3
echo mv ${reorder_file}_tmp3 ${reorder_file}
mv ${reorder_file}_tmp3 ${reorder_file}
echo rm -f ${reorder_file}_tmp2
rm -f ${reorder_file}_tmp2
echo rm -f ${reorder_file}_tmp1
rm -f ${reorder_file}_tmp1
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Run the JBB script, collecting data on the way.
# $1 = "client" or "server"
# $2 = name of reorder file to be generated.
echo "TEST_SERVER $1 $2."
test_setup $1 $2
echo "TEST_SERVER $1 $2."
rm -f ${reorder_file}_tmp1
rm -f ${reorder_file}_tmp2
heap=200m
( cd $jbb_dir; LD_PRELOAD=$mcount MCOUNT_ORDER_BY_COUNT=1 \
$testjava ${shared_server} -classpath $CLASSPATH -Xms${heap} -Xmx${heap} \
cat ${reorder_file}_tmp2 >> ${reorder_file}
rm -f ${reorder_file}_tmp2
rm -f ${reorder_file}_tmp1
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Rename the old VMs, copy the new in, run the test, and put the
# old one back.
# $1 = "client" or "server"
# $2 = name of reorder file to be generated.
# $3 = profiled jvm to copy in
echo "COPY_AND_TEST ($1, $2, $3)."
# $2 = name of reorder file to be generated.
# $3 = profiled jvm to copy in
cp $3 $lib/jvm_profiled
test_$1 $1 $2
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Check arguments:
if [ $# != 3 ] ; then
echo ""
echo "Usage:"
echo " sh reorder.sh <test_sdk_workspace> <test_sdk> <jbb_dir>"
echo ""
exit 1
fi
sdk_ws=$1
echo ""
echo ""
exit 1
fi
sdk=$2
# Set up architecture names as needed by various components.
# Why couldn't we just use x86 for everything?
# Arch name as used in JRE runtime (eg. i386):
# Arch name as used in Hotspot build: (eg. i486)
# Arch name as used in SDK build (eg. i586):
# Tweak for 64-bit sparc builds. At least they all agree.
fi
# Tweak for 64-bit i386 == amd64 builds. At least they all agree.
fi
# Tweak for x86 builds. All different.
fi
echo ""
echo ""
exit 1
fi
jbb_dir=$3
echo ""
echo ""
exit 1
fi
# Were profiled VMs built?
if [ "X$LP64" != "X" ] ; then
echo ""
echo "Profiled builds of compiler2 are needed first."
echo ' -- build with "make profiled PROFILE_PRODUCT=1" -- '
exit 1
fi
else
echo ""
echo "Profiled builds of compiler1 and compiler2 are needed first."
echo ' -- build with "make profiled{,1} PROFILE_PRODUCT=1" -- '
exit 1
fi
fi
# Compiler1 - not supported in 64-bit (b69 java launcher rejects it).
if [ "X$LP64" = "X" ] ; then
#gnumake profiled1
echo
fi
#gnumake profiled
echo