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 # --dev -- development mode (print the vm invocation cmdline) 13 # --no-verify -- turn off verification (on by default) 14 # --no-optimize -- turn off optimization (on by default) 15 # --no-precise -- turn off precise GC (on by default) 16 17 msg() { 18 if [ "$QUIET" = "n" ]; then 19 echo "$@" 20 fi 21 } 22 23 INTERP="" 24 DEBUG="n" 25 VERIFY="y" 26 OPTIMIZE="y" 27 QUIET="n" 28 PRECISE="y" 29 DEV_MODE="n" 30 31 while true; do 32 if [ "x$1" = "x--quiet" ]; then 33 QUIET="y" 34 shift 35 elif [ "x$1" = "x--fast" ]; then 36 INTERP="fast" 37 msg "Using fast interpreter" 38 shift 39 elif [ "x$1" = "x--jit" ]; then 40 INTERP="jit" 41 msg "Using jit" 42 shift 43 elif [ "x$1" = "x--portable" ]; then 44 INTERP="portable" 45 msg "Using portable interpreter" 46 shift 47 elif [ "x$1" = "x--debug" ]; then 48 DEBUG="y" 49 shift 50 elif [ "x$1" = "x--dev" ]; then 51 DEV_MODE="y" 52 shift 53 elif [ "x$1" = "x--no-verify" ]; then 54 VERIFY="n" 55 shift 56 elif [ "x$1" = "x--no-optimize" ]; then 57 OPTIMIZE="n" 58 shift 59 elif [ "x$1" = "x--no-precise" ]; then 60 PRECISE="n" 61 shift 62 elif [ "x$1" = "x--" ]; then 63 shift 64 break 65 elif expr "x$1" : "x--" >/dev/null 2>&1; then 66 echo "unknown option: $1" 1>&2 67 exit 1 68 else 69 break 70 fi 71 done 72 73 if [ "x$INTERP" = "x" ]; then 74 INTERP="jit" 75 msg "Using jit by default" 76 fi 77 78 if [ "$OPTIMIZE" = "y" ]; then 79 if [ "$VERIFY" = "y" ]; then 80 DEX_OPTIMIZE="-Xdexopt:verified" 81 else 82 DEX_OPTIMIZE="-Xdexopt:all" 83 fi 84 msg "Performing optimizations" 85 else 86 DEX_OPTIMIZE="-Xdexopt:none" 87 msg "Skipping optimizations" 88 fi 89 90 if [ "$VERIFY" = "y" ]; then 91 DEX_VERIFY="" 92 msg "Performing verification" 93 else 94 DEX_VERIFY="-Xverify:none" 95 msg "Skipping verification" 96 fi 97 98 msg "------------------------------" 99 100 if [ "$QUIET" = "n" ]; then 101 adb push test.jar /data 102 adb push test-ex.jar /data 103 else 104 adb push test.jar /data >/dev/null 2>&1 105 adb push test-ex.jar /data >/dev/null 2>&1 106 fi 107 108 if [ "$DEBUG" = "y" ]; then 109 DEX_DEBUG="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y" 110 fi 111 112 if [ "$PRECISE" = "y" ]; then 113 GC_OPTS="-Xgc:precise -Xgenregmap" 114 else 115 GC_OPTS="-Xgc:noprecise" 116 fi 117 118 cmdline="cd /data; dalvikvm $DEX_VERIFY $DEX_OPTIMIZE $DEX_DEBUG \ 119 $GC_OPTS -cp test.jar -Xint:${INTERP} -ea Main" 120 if [ "$DEV_MODE" = "y" ]; then 121 echo $cmdline "$@" 122 fi 123 adb shell $cmdline "$@" 124