blob: 436f262bb3682d5b6a6c408f02159ab5da205eca [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001#!/bin/bash
2# Copyright 2012 the V8 project authors. All rights reserved.
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are
5# met:
6#
7# * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9# * Redistributions in binary form must reproduce the above
10# copyright notice, this list of conditions and the following
11# disclaimer in the documentation and/or other materials provided
12# with the distribution.
13# * Neither the name of Google Inc. nor the names of its
14# contributors may be used to endorse or promote products derived
15# from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
28
29# Runs d8 with the given arguments on the device under 'perf' and
30# processes the profiler trace and v8 logs using ll_prof.py.
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.
40
41MODE=$1
42RUN_ARGS=$2
43LL_PROF_ARGS=$3
44
45BASE=`cd $(dirname "$0")/..; pwd`
46DEPLOY="$BASE/deploy"
47
48set +e
49mkdir -p "$DEPLOY/data/local/tmp/v8"
50
51cp "$BASE/out/android_arm.$MODE/d8" "$DEPLOY/data/local/tmp/v8/d8"
52
53adb -p "$DEPLOY" sync data
54
55adb 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"
58
59adb pull /data/local/tmp/v8/v8.log .
60adb pull /data/local/tmp/v8/v8.log.ll .
61adb pull /data/perf.data .
62
63ARCH=arm-linux-androideabi-4.6
64TOOLCHAIN="${ANDROID_NDK_ROOT}/toolchains/$ARCH/prebuilt/linux-x86/bin"
65
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