hotspot/test/compiler/unsafe/generate-unsafe-tests.sh
changeset 36316 7a83de7aabca
equal deleted inserted replaced
36315:150a415079ae 36316:7a83de7aabca
       
     1 #!/bin/bash
       
     2 
       
     3 javac -d . ../../../../jdk/make/src/classes/build/tools/spp/Spp.java
       
     4 
       
     5 SPP=build.tools.spp.Spp
       
     6 
       
     7 # Generates unsafe access tests for objects and all primitive types
       
     8 # $1 = package name to Unsafe, sun.misc | jdk.internal.misc
       
     9 # $2 = test class qualifier name, SunMisc | JdkInternalMisc
       
    10 function generate {
       
    11     package=$1
       
    12     Qualifier=$2
       
    13 
       
    14     for type in boolean byte short char int long float double Object
       
    15     do
       
    16       Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}"
       
    17       args="-K$type -Dtype=$type -DType=$Type"
       
    18 
       
    19       case $type in
       
    20         Object|int|long)
       
    21           args="$args -KCAS -KOrdered"
       
    22           ;;
       
    23       esac
       
    24 
       
    25       case $type in
       
    26         int|long)
       
    27           args="$args -KAtomicAdd"
       
    28           ;;
       
    29       esac
       
    30 
       
    31       case $type in
       
    32         short|char|int|long)
       
    33           args="$args -KUnaligned"
       
    34           ;;
       
    35       esac
       
    36 
       
    37       case $type in
       
    38         boolean)
       
    39           value1=true
       
    40           value2=false
       
    41           value3=false
       
    42           ;;
       
    43         byte)
       
    44           value1=(byte)1
       
    45           value2=(byte)2
       
    46           value3=(byte)3
       
    47           ;;
       
    48         short)
       
    49           value1=(short)1
       
    50           value2=(short)2
       
    51           value3=(short)3
       
    52           ;;
       
    53         char)
       
    54           value1=\'a\'
       
    55           value2=\'b\'
       
    56           value3=\'c\'
       
    57           ;;
       
    58         int)
       
    59           value1=1
       
    60           value2=2
       
    61           value3=3
       
    62           ;;
       
    63         long)
       
    64           value1=1L
       
    65           value2=2L
       
    66           value3=3L
       
    67           ;;
       
    68         float)
       
    69           value1=1.0f
       
    70           value2=2.0f
       
    71           value3=3.0f
       
    72           ;;
       
    73         double)
       
    74           value1=1.0d
       
    75           value2=2.0d
       
    76           value3=3.0d
       
    77           ;;
       
    78         Object)
       
    79           value1=\"foo\"
       
    80           value2=\"bar\"
       
    81           value3=\"baz\"
       
    82           ;;
       
    83       esac
       
    84 
       
    85       args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3"
       
    86 
       
    87       echo $args
       
    88 
       
    89       java $SPP -nel -K$Qualifier -Dpackage=$package -DQualifier=$Qualifier \
       
    90           $args < X-UnsafeAccessTest.java.template > ${Qualifier}UnsafeAccessTest${Type}.java
       
    91     done
       
    92 }
       
    93 
       
    94 generate sun.misc SunMisc
       
    95 generate jdk.internal.misc JdkInternalMisc
       
    96 
       
    97 rm -fr build