1 # Copyright (c) 2017, 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 pushd `dirname $0` > /dev/null
  23 DIR=`pwd`
  24 popd > /dev/null
  25 
  26 # set env variables
  27 . $DIR/test-env.sh
  28 
  29 rm -f libHelloWorld*.$SO_TYPE HelloWorld.class
  30 
  31 $JAVA_HOME/bin/javac -d . $DIR/HelloWorld.java
  32 
  33 # Run once with non-compressed oops.
  34 OPTS="-J-Xmx4g -J-XX:-UseCompressedOops --info --verbose"
  35 $JAVA_HOME/bin/jaotc $OPTS --output libHelloWorld.$SO_TYPE HelloWorld.class || exit 1
  36 
  37 JAVA_OPTS="-Xmx4g -XX:-UseCompressedOops -XX:+UnlockDiagnosticVMOptions -XX:+UseAOTStrictLoading -XX:AOTLibrary=./libHelloWorld.$SO_TYPE"
  38 
  39 $JAVA_HOME/bin/java $JAVA_OPTS -XX:+PrintAOT -version | grep "aot library" || exit 1
  40 $JAVA_HOME/bin/java $JAVA_OPTS HelloWorld || exit 1
  41 
  42 TIMEFORMAT="%3R"
  43 N=5
  44 
  45 LIBRARY=libHelloWorld-coop.$SO_TYPE
  46 
  47 for gc in UseG1GC UseParallelGC; do
  48     # Now with compressed oops.
  49     OPTS="-J-XX:+UseCompressedOops -J-XX:+$gc --info --verbose"
  50     $JAVA_HOME/bin/jaotc $OPTS --output $LIBRARY HelloWorld.class
  51 
  52     # Dump CDS archive.
  53     $JAVA_HOME/bin/java -Xshare:dump -XX:-UseAOT -XX:+$gc || exit 1
  54 
  55     JAVA_OPTS="-Xmx256m"
  56 
  57     echo "Tiered C1 $gc:"
  58     for i in `seq 1 $N`; do
  59         OUT=`time $JAVA_HOME/bin/java -XX:+$gc -XX:-UseCompressedOops -XX:-UseAOT -XX:TieredStopAtLevel=1 $JAVA_OPTS HelloWorld`
  60         if [ "$OUT" != "Hello, world!" ]; then
  61             echo $OUT
  62             exit 1
  63         fi
  64     done
  65 
  66     echo "Tiered C1/C2 $gc:"
  67     for i in `seq 1 $N`; do
  68         OUT=`time $JAVA_HOME/bin/java -XX:+$gc -XX:-UseCompressedOops -XX:-UseAOT $JAVA_OPTS HelloWorld`
  69         if [ "$OUT" != "Hello, world!" ]; then
  70             echo $OUT
  71             exit 1
  72         fi
  73     done
  74 
  75     JAVA_OPTS="-Xmx256m -XX:+UseCompressedOops -XX:+UnlockDiagnosticVMOptions -XX:+UseAOTStrictLoading -XX:AOTLibrary=./$LIBRARY"
  76 
  77 
  78     echo "AOT $gc:"
  79     for i in `seq 1 $N`; do
  80         OUT=`time $JAVA_HOME/bin/java -XX:+$gc $JAVA_OPTS HelloWorld`
  81         if [ "$OUT" != "Hello, world!" ]; then
  82             echo $OUT
  83             exit 1
  84         fi
  85     done
  86 
  87     echo "AOT -Xshare:on $gc:"
  88     for i in `seq 1 $N`; do
  89         OUT=`time $JAVA_HOME/bin/java -Xshare:on -XX:+$gc $JAVA_OPTS HelloWorld`
  90         if [ "$OUT" != "Hello, world!" ]; then
  91             echo $OUT
  92             exit 1
  93         fi
  94     done
  95 done
  96 
  97 rm -f libHelloWorld*.$SO_TYPE HelloWorld.class