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