blob: df66a8eedf3622fda9a8cff5a91a1221cd38e5b6 [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001#!/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)
Ben Cheng38329f52009-07-07 14:19:20 -07009# --jit -- use the jit
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080010# --portable -- use the portable interpreter
11# --debug -- wait for debugger to attach
12# --zygote -- use the zygote (if so, all other options are ignored)
Andy McFadden09e83b72009-04-02 10:53:00 -070013# --dev -- development mode
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080014# --no-verify -- turn off verification (on by default)
15# --no-optimize -- turn off optimization (on by default)
Andy McFadden09e83b72009-04-02 10:53:00 -070016# --no-precise -- turn off precise GC (on by default)
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080017
18msg() {
19 if [ "$QUIET" = "n" ]; then
20 echo "$@"
21 fi
22}
23
24INTERP=""
25DEBUG="n"
26VERIFY="y"
27OPTIMIZE="y"
28ZYGOTE="n"
29QUIET="n"
Andy McFadden49a71d12009-03-24 21:19:24 -070030PRECISE="y"
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080031
32while 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
Ben Cheng38329f52009-07-07 14:19:20 -070040 elif [ "x$1" = "x--jit" ]; then
41 INTERP="jit"
42 msg "Using jit"
43 shift
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080044 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
Andy McFadden09e83b72009-04-02 10:53:00 -070055 elif [ "x$1" = "x--dev" ]; then
56 # not used; ignore
57 shift
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080058 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
Andy McFadden49a71d12009-03-24 21:19:24 -070064 elif [ "x$1" = "x--no-precise" ]; then
65 PRECISE="n"
66 shift
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080067 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
76done
77
78if [ "$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
103fi
104
105msg "------------------------------"
106
107if [ "$QUIET" = "n" ]; then
108 adb push test.jar /data
109 adb push test-ex.jar /data
110else
111 adb push test.jar /data >/dev/null 2>&1
112 adb push test-ex.jar /data >/dev/null 2>&1
113fi
114
115if [ "$DEBUG" = "y" ]; then
116 DEX_DEBUG="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y"
117fi
118
Andy McFadden49a71d12009-03-24 21:19:24 -0700119if [ "$PRECISE" = "y" ]; then
120 GC_OPTS="-Xgc:precise -Xgenregmap"
121else
122 GC_OPTS="-Xgc:noprecise"
123fi
124
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800125if [ "$ZYGOTE" = "y" ]; then
126 adb shell cd /data \; dvz -classpath test.jar Main "$@"
127else
128 adb shell cd /data \; dalvikvm $DEX_VERIFY $DEX_OPTIMIZE $DEX_DEBUG \
Andy McFadden49a71d12009-03-24 21:19:24 -0700129 $GC_OPTS -cp test.jar "-Xint:${INTERP}" -ea Main "$@"
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800130fi