android-ll-prof.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/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. # Runs d8 with the given arguments on the device under 'perf' and
  29. # processes the profiler trace and v8 logs using ll_prof.py.
  30. #
  31. # Usage:
  32. # > ./tools/android-ll-prof.sh (debug|release) "args to d8" "args to ll_prof.py"
  33. #
  34. # The script creates deploy directory deploy/data/local/tmp/v8, copies there
  35. # the d8 binary either from out/android_arm.release or out/android_arm.debug,
  36. # and then sync the deploy directory with /data/local/tmp/v8 on the device.
  37. # You can put JS files in the deploy directory before running the script.
  38. # Note: $ANDROID_NDK_ROOT must be set.
  39. MODE=$1
  40. RUN_ARGS=$2
  41. LL_PROF_ARGS=$3
  42. BASE=`cd $(dirname "$0")/..; pwd`
  43. DEPLOY="$BASE/deploy"
  44. set +e
  45. mkdir -p "$DEPLOY/data/local/tmp/v8"
  46. cp "$BASE/out/android_arm.$MODE/d8" "$DEPLOY/data/local/tmp/v8/d8"
  47. adb -p "$DEPLOY" sync data
  48. adb shell "cd /data/local/tmp/v8;\
  49. perf record -R -e cycles -c 10000 -f -i \
  50. ./d8 --ll_prof --gc-fake-mmap=/data/local/tmp/__v8_gc__ $RUN_ARGS"
  51. adb pull /data/local/tmp/v8/v8.log .
  52. adb pull /data/local/tmp/v8/v8.log.ll .
  53. adb pull /data/perf.data .
  54. ARCH=arm-linux-androideabi-4.6
  55. TOOLCHAIN="${ANDROID_NDK_ROOT}/toolchains/$ARCH/prebuilt/linux-x86/bin"
  56. $BASE/tools/ll_prof.py --host-root="$BASE/deploy" \
  57. --gc-fake-mmap=/data/local/tmp/__v8_gc__ \
  58. --objdump="$TOOLCHAIN/arm-linux-androideabi-objdump" \
  59. $LL_PROF_ARGS