v8/tools/find-builtin
Leszek Swirski 9d33c4e68e [tools] Add a tool for finding builtins
Example usage:
    tools/find-builtin LoadIC | xargs code -g

Change-Id: I12c15d3d4a80edbcddfa9cc8b9a515b839c96fdf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2808949
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73827}
2021-04-07 12:51:38 +00:00

24 lines
628 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
BUILTIN_NAME="$1"
if ! which rg >/dev/null ; then
echo >&2 "This tool requires 'rg', install it with 'sudo apt install ripgrep'"
exit 1
fi
TOOLS_DIRNAME="$(dirname "$0")"
V8_DIRNAME="$(dirname "$TOOLS_DIRNAME")"
if rg --type-add 'tq:*.tq' --type tq --with-filename --line-number "\bbuiltin $BUILTIN_NAME\b" "$V8_DIRNAME" | rg -v '\bextern builtin\b' | cut -f1-2 -d: ; then
exit 0
fi
if rg --type cpp --with-filename --line-number "\b(TF_BUILTIN\(|::Generate_?)$BUILTIN_NAME\b" "$V8_DIRNAME" | cut -f1-2 -d: ; then
exit 0
fi
echo >&2 "Builtin '$BUILTIN_NAME' not found"
exit 1