#/bin/bash

#JVM to execute the compilation process with
JVM=~/bin/ibm-java2-x86_64-50/bin/java

#JRE with which the benchmarks are linked
JRELIB=~/bin/sun-jdk1.4.2_12/jre/lib

LASTSTAGE=$3
ABC=../abc-complete.jar
DEPS=./dacapo/benchmarks/apps/$1-deps.jar:./dacapo/benchmarks/apps/batik.jar
ABC_RT=../abc-runtime.jar
JCE=${JRELIB}/jce.jar
RT=${JRELIB}/rt.jar:${JRELIB}/jsse.jar

#=====

#STARTTIME=`date +%Y%m%d`

DIR=../optimized

mkdir -p ${DIR}

echo Compiling $1/$2 with last stage $3.
echo Generating output in ${DIR}/$1-$2.{jar,log}

${JVM} -Xmx3072m -Xss2048k -cp ${ABC} \
abc.main.Main -ext abc.tm \
  -cp ${ABC_RT}:${JCE}:${RT}:${DEPS} \
  -injars ./dacapo/benchmarks/apps/$1.jar \
  -outjar ${DIR}/$1-$2.jar \
  -main-class dacapo.$1.Main \
-debug dontCheckExceptions \
-tmopt \
-laststage ${LASTSTAGE} \
-debug tmShadowStatistics \
-debug csv \
-debug tmShadowDump \
../tracematches/$2.java \
>${DIR}/$1-$2.log 2>&1
