Bug 615159 - nanojit: test both SSE2 and non-SSE2 code on tinderbox. r=Jacob.Bramley.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 07 Dec 2010 13:54:33 -0800
changeset 58987 79f9bf0c6146aeb8da750dbc00419fdbcf9e7827
parent 58986 dadc1d60b6f3e5acc0213224d4488601f1c03d18
child 58988 9c48c587352a4935450991a826f344f7cba26219
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersJacob
bugs615159
milestone2.0b8pre
Bug 615159 - nanojit: test both SSE2 and non-SSE2 code on tinderbox. r=Jacob.Bramley.
js/src/lirasm/lirasm.cpp
js/src/lirasm/testlirc.sh
--- a/js/src/lirasm/lirasm.cpp
+++ b/js/src/lirasm/lirasm.cpp
@@ -2224,28 +2224,35 @@ Lirasm::handlePatch(LirTokenStream &in)
 }
 
 void
 usageAndQuit(const string& progname)
 {
     cout <<
         "usage: " << progname << " [options] [filename]\n"
         "Options:\n"
-        "  -h --help        print this message\n"
-        "  -v --verbose     print LIR and assembly code\n"
-        "  --execute        execute LIR\n"
-        "  --[no-]optimize  enable or disable optimization of the LIR (default=off)\n"
-        "  --random [N]     generate a random LIR block of size N (default=1000)\n"
-        "  --word-size      prints the word size (32 or 64) for this build of lirasm and exits\n"
-        "  --endianness     prints endianness (little-endian or big-endian) for this build of librasm and exits\n"
-        " i386-specific options:\n"
-        "  --sse            use SSE2 instructions\n"
-        " ARM-specific options:\n"
-        "  --arch N         generate code for ARM architecture version N (default=7)\n"
-        "  --[no]vfp        enable or disable the generation of ARM VFP code (default=on)\n"
+        "  -h --help         print this message\n"
+        "  -v --verbose      print LIR and assembly code\n"
+        "  --execute         execute LIR\n"
+        "  --[no-]optimize   enable or disable optimization of the LIR (default=off)\n"
+        "  --random [N]      generate a random LIR block of size N (default=1000)\n"
+        "\n"
+        "Build query options (these print a value for this build of lirasm and exit)\n"
+        "  --show-arch       show the architecture ('i386', 'X64', 'arm', 'ppc',\n"
+        "                    'sparc', 'mips', or 'sh4')\n"
+        "  --show-word-size  show the word size ('32' or '64')\n"
+        "  --show-endianness show the endianness ('little-endian' or 'big-endian')\n"
+        "\n"
+        "i386-specific options:\n"
+        "  --[no]sse         use SSE2 instructions (default=on)\n"
+        "\n"
+        "ARM-specific options:\n"
+        "  --arch N          use ARM architecture version N instructions (default=7)\n"
+        "  --[no]vfp         use ARM VFP instructions (default=on)\n"
+        "\n"
         ;
     exit(0);
 }
 
 void
 errMsgAndQuit(const string& progname, const string& msg)
 {
     cerr << progname << ": " << msg << endl;
@@ -2267,17 +2274,17 @@ processCmdLine(int argc, char **argv, Cm
     opts.progname = argv[0];
     opts.verbose  = false;
     opts.execute  = false;
     opts.random   = 0;
     opts.optimize = false;
 
     // Architecture-specific options.
 #if defined NANOJIT_IA32
-    bool            i386_sse = false;
+    bool            i386_sse = true;
 #elif defined NANOJIT_ARM
     unsigned int    arm_arch = 7;
     bool            arm_vfp = true;
 #endif
 
     for (int i = 1; i < argc; i++) {
         string arg = argv[i];
 
@@ -2305,35 +2312,60 @@ processCmdLine(int argc, char **argv, Cm
                         errMsgAndQuit(opts.progname, "--random argument must be greater than zero");
                     opts.random = res;          // next arg is a number, use that for the size
                     i++;
                 } else {
                     opts.random = defaultSize;  // next arg is not a number
                 }
             }
         }
-        else if (arg == "--word-size") {
+        else if (arg == "--show-arch") {
+            const char* str = 
+#if defined NANOJIT_IA32
+                "i386";
+#elif defined NANOJIT_X64
+                "X64";
+#elif defined NANOJIT_ARM
+                "arm";
+#elif defined NANOJIT_PPC
+                "ppc";
+#elif defined NANOJIT_SPARC
+                "sparc";
+#elif defined NANOJIT_MIPS
+                "mips";
+#elif defined NANOJIT_SH4
+                "sh4";
+#else
+#               error "unknown arch"
+#endif
+            cout << str << "\n";
+            exit(0);
+        }
+        else if (arg == "--show-word-size") {
             cout << sizeof(void*) * 8 << "\n";
             exit(0);
         }
-        else if (arg == "--endianness") {
+        else if (arg == "--show-endianness") {
             int32_t x = 0x01020304;
             if (*(char*)&x == 0x1) {
               cout << "big-endian" << "\n";
             } else {
               cout << "little-endian" << "\n";
             }
             exit(0);
         }
 
         // Architecture-specific flags.
 #if defined NANOJIT_IA32
         else if (arg == "--sse") {
             i386_sse = true;
         }
+        else if (arg == "--nosse") {
+            i386_sse = false;
+        }
 #elif defined NANOJIT_ARM
         else if ((arg == "--arch") && (i < argc-1)) {
             char* endptr;
             arm_arch = strtoul(argv[i+1], &endptr, 10);
             // Check that the argument was a number.
             if ('\0' == *endptr) {
                 if ((arm_arch < 4) || (arm_arch > 7)) {
                     errMsgAndQuit(opts.progname, "Unsupported argument to --arm-arch.\n");
--- a/js/src/lirasm/testlirc.sh
+++ b/js/src/lirasm/testlirc.sh
@@ -8,134 +8,141 @@ LIRASM=$1
 
 TESTS_DIR=`dirname "$0"`/tests
 
 function runtest {
     local infile=$1
     local options=${2-}
 
     # Catch a request for the random tests.
-    if [[ $infile == --random* ]]
-    then
+    if [[ $infile == --random* ]] ; then
         local outfile=$TESTS_DIR/random.out
     else
         local outfile=`echo $infile | sed 's/\.in/\.out/'`
     fi
 
-    if [[ ! -e "$outfile" ]]
-    then
+    if [[ ! -e "$outfile" ]] ; then
         echo "$0: error: no out file $outfile"
         exit 1
     fi
 
     # sed used to strip extra leading zeros from exponential values 'e+00' (see bug 602786)
-    if $LIRASM $options --execute $infile | tr -d '\r' | sed -e 's/e+00*/e+0/g' > testoutput.txt && cmp -s testoutput.txt $outfile
-    then
+    if $LIRASM $options --execute $infile | tr -d '\r' | sed -e 's/e+00*/e+0/g' > testoutput.txt && cmp -s testoutput.txt $outfile ; then
         echo "TEST-PASS | lirasm | lirasm $options --execute $infile"
     else
         echo "TEST-UNEXPECTED-FAIL | lirasm | lirasm $options --execute $infile"
         echo "expected output"
         cat $outfile
         echo "actual output"
         cat testoutput.txt
         exitcode=1
     fi
 }
 
-# Tests common to all supported back-ends.
-for infile in "$TESTS_DIR"/*.in
-do
-    runtest $infile
-done
-
-# ---- Platform-specific tests and configurations. ----
+function runtests {
+    local testdir=$1
+    local options=${2-}
+    for infile in "$TESTS_DIR"/"$testdir"/*.in ; do
+        runtest $infile $options
+    done
+}
 
-# Tests for hardware floating-point.
-# These tests use LIR instructions which are normally removed by the soft-float
-# filter, so soft-float targets do not need to support them.
-#
-# There is no conditional check for hardfloat support as every platform appears
-# to support it. If the default for a particular platform does not support
-# hardfloat, exclude the hardfloat tests (based on something like "uname -m").
-for infile in "$TESTS_DIR"/hardfloat/*.in
-do
-    runtest $infile
-done
+if [[ $($LIRASM --show-arch 2>/dev/null) == "i386" ]] ; then
+    # i386 with SSE2.
+    runtests "."
+    runtests "hardfloat"
+    runtests "32-bit"
+    runtests "littleendian"
+    runtest "--random 1000000"
+    runtest "--random 1000000 --optimize"
+
+    # i386 without SSE2.
+    runtests "."               "--nosse"
+    runtests "hardfloat"       "--nosse"
+    runtests "32-bit"          "--nosse"
+    runtests "littleendian"    "--nosse"
+    runtest "--random 1000000" "--nosse"
 
-# 64-bit platforms
-if [[ $($LIRASM --word-size) == 64 ]]
-then
-    for infile in "$TESTS_DIR"/64-bit/*.in
-    do
-        runtest $infile
-    done
-fi
+elif [[ $($LIRASM --show-arch 2>/dev/null) == "X64" ]] ; then
+    # X64.
+    runtests "."
+    runtests "hardfloat"
+    runtests "64-bit"
+    runtests "littleendian"
+    runtest "--random 1000000"
+    runtest "--random 1000000 --optimize"
 
-# 32-bit platforms
-if [[ $($LIRASM --word-size) == 32 ]]
-then
-    for infile in "$TESTS_DIR"/32-bit/*.in
-    do
-        runtest $infile
-    done
-fi
+elif [[ $($LIRASM --show-arch 2>/dev/null) == "arm" ]] ; then
+    # ARMv7 with VFP.  We could test without VFP but such a platform seems
+    # unlikely.  ARM is bi-endian but usually configured as little-endian.
+    runtests "."
+    runtests "hardfloat"
+    runtests "32-bit"
+    runtests "littleendian"
+    runtest "--random 1000000"
+    runtest "--random 1000000" "--optimize"
 
-# little endian
-if [[ $($LIRASM --endianness 2>/dev/null) != "big-endian" ]]
-then
-    for infile in "$TESTS_DIR"/littleendian/*.in
-    do
-        runtest $infile
-    done
-fi
+    # ARMv6 with VFP.  ARMv6 without VFP doesn't seem worth testing.
+    # Random tests are reduced.
+    runtests "."              "--arch 6"
+    runtests "hardfloat"      "--arch 6"
+    runtests "32-bit"         "--arch 6"
+    runtests "littleendian"   "--arch 6"
+    runtest "--random 100000" "--arch 6"
 
-# big endian
-if [[ $($LIRASM --endianness 2>/dev/null) == "big-endian" ]]
-then
-    for infile in "$TESTS_DIR"/bigendian/*.in
-    do
-        runtest $infile
-    done
-fi
+    # ARMv5 without VFP.  ARMv5 with VFP doesn't seem worth testing.
+    # Random tests are reduced.
+    runtests "."              "--arch 5 --novfp"
+    runtests "softfloat"      "--arch 5 --novfp"
+    runtests "32-bit"         "--arch 5 --novfp"
+    runtests "littleendian"   "--arch 5 --novfp"
+    runtest "--random 100000" "--arch 5 --novfp"
 
-# ARM
-if [[ $(uname -m) == arm* ]]
-then
-    for infile in "$TESTS_DIR"/*.in
-    do
-        # Run standard tests, but set code generation for older architectures.
-        # It may also be beneficial to test ARMv6 and ARMv7 with --novfp, but such
-        # a platform seems so unlikely that it probably isn't worthwhile. It's also
-        # unlikely that it's worth testing ARMv5 with VFP.
-        runtest $infile "--arch 6"
-        runtest $infile "--arch 5 --novfp"
-    done
+elif [[ $($LIRASM --show-arch 2>/dev/null) == "ppc" ]] ; then
+    # PPC is bi-endian but usually configured as big-endian.
+    runtests "."
+    runtests "hardfloat"
+    if [[ $($LIRASM --show-word-size) == "32" ]] ; then
+        runtests "32-bit"
+    else
+        runtests "64-bit"
+    fi
+    runtests "bigendian"
+    runtest "--random 1000000"
+    runtest "--random 1000000 --optimize"
 
-    for infile in "$TESTS_DIR"/hardfloat/*.in
-    do
-        # Run tests that require hardware floating-point.
-        runtest $infile "--arch 6"
-    done
+elif [[ $($LIRASM --show-arch 2>/dev/null) == "sparc" ]] ; then
+    # Sparc is bi-endian but usually configured as big-endian.
+    runtests "."
+    runtests "hardfloat"
+    runtests "32-bit"
+    runtests "bigendian"
+    runtest "--random 1000000"
+    runtest "--random 1000000 --optimize"
 
-    # Run specific soft-float tests, but only for ARMv5 without VFP.
-    # NOTE: It looks like MIPS ought to be able to run these tests, but I can't
-    # test this and _not_ running them seems like the safest option.
-    for infile in "$TESTS_DIR"/softfloat/*.in
-    do
-        runtest $infile "--arch 5 --novfp"
-    done
+elif [[ $($LIRASM --show-arch 2>/dev/null) == "mips" ]] ; then
+    # MIPS is bi-endian but usually configured as big-endian.
+    # XXX: should we run softfloat tests as well?  Seems to depend on
+    # the configuration...
+    runtests "."
+    runtests "hardfloat"
+    runtests "32-bit"
+    runtests "bigendian"
+    runtest "--random 1000000"
+    runtest "--random 1000000 --optimize"
 
-    # Run reduced random tests for these targets. (The default ARMv7 target
-    # still runs the long tests.)
-    runtest "--random 10000 --arch 6"
-    runtest "--random 10000 --arch 5 --novfp"
-    runtest "--random 10000 --optimize --arch 6"
-    runtest "--random 10000 --optimize --arch 5 --novfp"
+elif [[ $($LIRASM --show-arch 2>/dev/null) == "sh4" ]] ; then
+    # SH4 is bi-endian but usually configured as big-endian.
+    runtests "."
+    runtests "hardfloat"
+    runtests "32-bit"
+    runtests "bigendian"
+    runtest "--random 1000000"
+    runtest "--random 1000000 --optimize"
+
+else
+    echo "bad arch"
+    exit 1
 fi
 
-# ---- Randomized tests, they are run last because they are slow ----
-
-runtest "--random 1000000"
-runtest "--random 1000000 --optimize"
-
 rm testoutput.txt
 
 exit $exitcode