1 #!/bin/sh 2 # 3 # Run the code in test.jar on the device. The jar should contain a top-level 4 # class named Main to run. 5 # 6 # Options: 7 # --quiet -- don't chatter 8 # --fast -- use the fast interpreter (the default) 9 # --jit -- use the jit 10 # --portable -- use the portable interpreter 11 # --debug -- wait for debugger to attach 12 # --zygote -- use the zygote (if so, all other options are ignored) 13 # --dev -- development mode 14 # --no-verify -- turn off verification (on by default) 15 # --no-optimize -- turn off optimization (on by default) 16 # --no-precise -- turn off precise GC (on by default) 17 18 msg() { 19 if [ "$QUIET" = "n" ]; then 20 echo "$@" 21 fi 22 } 23 24 INTERP="" 25 DEBUG="n" 26 VERIFY="y" 27 OPTIMIZE="y" 28 ZYGOTE="n" 29 QUIET="n" 30 PRECISE="y" 31 32 while true; do 33 if [ "x$1" = "x--quiet" ]; then 34 QUIET="y" 35 shift 36 elif [ "x$1" = "x--fast" ]; then 37 INTERP="fast" 38 msg "Using fast interpreter" 39 shift 40 elif [ "x$1" = "x--jit" ]; then 41 INTERP="jit" 42 msg "Using jit" 43 shift 44 elif [ "x$1" = "x--portable" ]; then 45 INTERP="portable" 46 msg "Using portable interpreter" 47 shift 48 elif [ "x$1" = "x--debug" ]; then 49 DEBUG="y" 50 shift 51 elif [ "x$1" = "x--zygote" ]; then 52 ZYGOTE="y" 53 msg "Spawning from zygote" 54 shift 55 elif [ "x$1" = "x--dev" ]; then 56 # not used; ignore 57 shift 58 elif [ "x$1" = "x--no-verify" ]; then 59 VERIFY="n" 60 shift 61 elif [ "x$1" = "x--no-optimize" ]; then 62 OPTIMIZE="n" 63 shift 64 elif [ "x$1" = "x--no-precise" ]; then 65 PRECISE="n" 66 shift 67 elif [ "x$1" = "x--" ]; then 68 shift 69 break 70 elif expr "x$1" : "x--" >/dev/null 2>&1; then 71 echo "unknown option: $1" 1>&2 72 exit 1 73 else 74 break 75 fi 76 done 77 78 if [ "$ZYGOTE" = "n" ]; then 79 if [ "x$INTERP" = "x" ]; then 80 INTERP="fast" 81 msg "Using fast interpreter by default" 82 fi 83 84 if [ "$OPTIMIZE" = "y" ]; then 85 if [ "$VERIFY" = "y" ]; then 86 DEX_OPTIMIZE="-Xdexopt:verified" 87 else 88 DEX_OPTIMIZE="-Xdexopt:all" 89 fi 90 msg "Performing optimizations" 91 else 92 DEX_OPTIMIZE="-Xdexopt:none" 93 msg "Skipping optimizations" 94 fi 95 96 if [ "$VERIFY" = "y" ]; then 97 DEX_VERIFY="" 98 msg "Performing verification" 99 else 100 DEX_VERIFY="-Xverify:none" 101 msg "Skipping verification" 102 fi 103 fi 104 105 msg "------------------------------" 106 107 if [ "$QUIET" = "n" ]; then 108 adb push test.jar /data 109 adb push test-ex.jar /data 110 else 111 adb push test.jar /data >/dev/null 2>&1 112 adb push test-ex.jar /data >/dev/null 2>&1 113 fi 114 115 if [ "$DEBUG" = "y" ]; then 116 DEX_DEBUG="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y" 117 fi 118 119 if [ "$PRECISE" = "y" ]; then 120 GC_OPTS="-Xgc:precise -Xgenregmap" 121 else 122 GC_OPTS="-Xgc:noprecise" 123 fi 124 125 if [ "$ZYGOTE" = "y" ]; then 126 adb shell cd /data \; dvz -classpath test.jar Main "$@" 127 else 128 adb shell cd /data \; dalvikvm $DEX_VERIFY $DEX_OPTIMIZE $DEX_DEBUG \ 129 $GC_OPTS -cp test.jar "-Xint:${INTERP}" -ea Main "$@" 130 fi 131