blob: e2fde428ee534a9c5965921a96b0fa56c460ff31 [file] [log] [blame]
jeffhao5d1ac922011-09-29 17:41:15 -07001#!/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
18msg() {
19 if [ "$QUIET" = "n" ]; then
20 echo "$@"
21 fi
22}
23
24INTERP=""
25DEBUG="n"
26VERIFY="y"
27OPTIMIZE="y"
28ZYGOTE="n"
29QUIET="n"
30PRECISE="y"
31DEV_MODE="n"
32
33while 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
77done
78
79if [ "$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
104fi
105
106msg "------------------------------"
107
108if [ "$QUIET" = "n" ]; then
109 adb push test.jar /data
110 adb push test-ex.jar /data
111else
112 adb push test.jar /data >/dev/null 2>&1
113 adb push test-ex.jar /data >/dev/null 2>&1
114fi
115
116if [ "$DEBUG" = "y" ]; then
117 DEX_DEBUG="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y"
118fi
119
120if [ "$PRECISE" = "y" ]; then
121 GC_OPTS="-Xgc:precise -Xgenregmap"
122else
123 GC_OPTS="-Xgc:noprecise"
124fi
125
126if [ "$ZYGOTE" = "y" ]; then
127 adb shell cd /data \; dvz -classpath test.jar Main "$@"
128else
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 "$@"
135fi