OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright 2012 the V8 project authors. All rights reserved. | 2 # Copyright 2012 the V8 project authors. All rights reserved. |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
11 # disclaimer in the documentation and/or other materials provided | 11 # disclaimer in the documentation and/or other materials provided |
12 # with the distribution. | 12 # with the distribution. |
13 # * Neither the name of Google Inc. nor the names of its | 13 # * Neither the name of Google Inc. nor the names of its |
14 # contributors may be used to endorse or promote products derived | 14 # contributors may be used to endorse or promote products derived |
15 # from this software without specific prior written permission. | 15 # from this software without specific prior written permission. |
16 # | 16 # |
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
29 # Checks that the number of compilation units having at least one static | 29 # Runs d8 with the given arguments on the device under 'perf' and |
30 # initializer in d8 matches the one defined below. | 30 # processes the profiler trace and v8 logs using ll_prof.py. |
31 # Note that the project must be built with SCons before running this script. | 31 # |
| 32 # Usage: |
| 33 # > ./tools/android-ll-prof.sh (debug|release) "args to d8" "args to ll_prof.py" |
| 34 # |
| 35 # The script creates deploy directory deploy/data/local/tmp/v8, copies there |
| 36 # the d8 binary either from out/android_arm.release or out/android_arm.debug, |
| 37 # and then sync the deploy directory with /data/local/tmp/v8 on the device. |
| 38 # You can put JS files in the deploy directory before running the script. |
| 39 # Note: $ANDROID_NDK_ROOT must be set. |
32 | 40 |
33 # Allow: | 41 MODE=$1 |
34 # - _GLOBAL__I__ZN2v810LineEditor6first_E | 42 RUN_ARGS=$2 |
35 # - _GLOBAL__I__ZN2v88internal32AtomicOps_Internalx86CPUFeaturesE | 43 LL_PROF_ARGS=$3 |
36 # - _GLOBAL__I__ZN2v88internal8ThreadId18highest_thread_id_E | |
37 expected_static_init_count=3 | |
38 | 44 |
39 v8_root=$(readlink -f $(dirname $BASH_SOURCE)/../) | 45 BASE=`cd $(dirname "$0")/..; pwd` |
| 46 DEPLOY="$BASE/deploy" |
40 | 47 |
41 if [ -n "$1" ] ; then | 48 set +e |
42 d8="${v8_root}/$1" | 49 mkdir -p "$DEPLOY/data/local/tmp/v8" |
43 else | |
44 d8="${v8_root}/d8" | |
45 fi | |
46 | 50 |
47 if [ ! -f "$d8" ]; then | 51 cp "$BASE/out/android_arm.$MODE/d8" "$DEPLOY/data/local/tmp/v8/d8" |
48 echo "d8 binary not found: $d8" | |
49 exit 1 | |
50 fi | |
51 | 52 |
52 static_inits=$(nm "$d8" | grep _GLOBAL_ | grep _I_ | awk '{ print $NF; }') | 53 adb -p "$DEPLOY" sync data |
53 | 54 |
54 static_init_count=$(echo "$static_inits" | wc -l) | 55 adb shell "cd /data/local/tmp/v8;\ |
| 56 perf record -R -e cycles -c 10000 -f -i \ |
| 57 ./d8 --ll_prof --gc-fake-mmap=/data/local/tmp/__v8_gc__ $RUN_ARGS" |
55 | 58 |
56 if [ $static_init_count -gt $expected_static_init_count ]; then | 59 adb pull /data/local/tmp/v8/v8.log . |
57 echo "Too many static initializers." | 60 adb pull /data/local/tmp/v8/v8.log.ll . |
58 echo "$static_inits" | 61 adb pull /data/perf.data . |
59 exit 1 | 62 |
60 else | 63 ARCH=arm-linux-androideabi-4.4.3 |
61 echo "Static initializer check passed ($static_init_count initializers)." | 64 TOOLCHAIN="${ANDROID_NDK_ROOT}/toolchains/$ARCH/prebuilt/linux-x86/bin" |
62 exit 0 | 65 |
63 fi | 66 $BASE/tools/ll_prof.py --host-root="$BASE/deploy" \ |
| 67 --gc-fake-mmap=/data/local/tmp/__v8_gc__ \ |
| 68 --objdump="$TOOLCHAIN/arm-linux-androideabi-objdump" \ |
| 69 $LL_PROF_ARGS |
OLD | NEW |