- git
First we have to install depot_tools
. You can clone that into your home directory or whatever you want
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
then insert absolute depot_tools
path to your PATH. To do that you have to add this line at the end of your ~/.bashrc
file (or .bash_profile
, or any file you're using as source)
export PATH=$PATH:/path/to/depot_tools
if you've cloned that repo into your home directory it's going to be
export PATH=$PATH:/home/<user_name>/depot_tools
At the end just call
source ~/.bashrc
To reload your source.
You should be able to call
gclient
from your terminal now
Now let's create folder when your V8 is going to be
mkdir ~/v8
cd ~/v8
Get V8 code and build dependencies
fetch v8
cd v8
// Install build dependencies (Linux needs it, Mac should have those already)
./build/install-build-deps.sh
// Get a coffee
let's compile our V8
tools/dev/gm.py x64.release.check
// Get another coffee, tidy up your room, do the laundry
You're basically done and your v8 is in ./out/x64.release/d8
If you don't want to use v8 like that
~/v8/v8/out/x64.release/d8 sth.js
every time you can to call it it's useful to add it into your .bashrc
file as alias (note that if you're Mac
use then linux-tick-processor
is mac-tick-processor
)
alias d8=/home/<user_name>/v8/v8/out/x64.release/d8
alias tick-processor=/home/<user_name>/v8/v8/tools/linux-tick-processor
alias ic-processor=/home/<user_name>/v8/v8/tools/ic-processor
export D8_PATH="/home/<user_name>/v8/v8/out/x64.release"
Now you can just call
d8 sth.js
Remember to call source ~/.bashrc
at the end, otherwise it won't be in your shell.
I'm calling V8 with
alias
setup in my bash profile file. If you didn't do that on your machine replaced8
with/path/to/my/v8/out/x64.release/d8
Every time you want to use V8 only thing you need to do is to call it and pass list of parameters with JS file
d8 --prof index.js
sometimes you may want to output print from V8 into text file (easier to read)
d8 --print-opt-code index.js > optcode.txt
After running --prof
you should have v8.log
file which is really hard to read. That's where tick-processor
comes in handy. Run tick-processor
(or full path to you linux-tick-processor
file) from withing folder with v8.log
file. You should see list of human readable statistics now.
The same goes for ic-processor
which is responsible for processing trace-ic
(inline cache).
All options are available when calling d8 --help
. I've just filtered more useful ones. Always use help to get latest list of features.
--use-strict (enforce strict mode)
type: bool default: false
--enable-one-shot-optimization (Enable size optimizations for the code that will only be executed once)
type: bool default: true
--use-ic (use inline caching)
type: bool default: true
--print-bytecode (print bytecode generated by ignition interpreter)
type: bool default: false
--print-bytecode-filter (filter for selecting which functions to print bytecode)
type: string default: *
--allow-natives-syntax (allow natives syntax, like %HaveSameMap)
type: bool default: false
--runtime-call-stats (report runtime call counts and times)
type: bool default: false
--serialization-statistics (Collect statistics on serialized objects.)
type: bool default: false
--prof (Log statistical profiling information (implies --log-code).)
type: bool default: false
--print-opt-source (print source code of optimized and inlined functions)
type: bool default: false
--print-code (print generated code)
type: bool default: false
--print-opt-code (print optimized code)
type: bool default: false
--print-code-verbose (print more information for code)
type: bool default: false
Logging
--log (Minimal logging (no API, code, GC, suspect, or handles samples).)
type: bool default: false
--log-all (Log all events to the log file.)
type: bool default: false
--log-api (Log API events to the log file.)
type: bool default: false
--log-code (Log code events to the log file without profiling.)
type: bool default: false
--log-handles (Log global handle events.)
type: bool default: false
--log-suspect (Log suspect operations.)
type: bool default: false
--log-source-code (Log source code.)
type: bool default: false
--log-function-events (Log function events (parse, compile, execute) separately.)
type: bool default: false
--log-internal-timer-events (Time internal events.)
type: bool default: false
And there is a hole bunch of tracking options
--trace-ignition-codegen (trace the codegen of ignition interpreter bytecode handlers)
type: bool default: false
--trace-ignition-dispatches (traces the dispatches to bytecode handlers by the ignition interpreter)
type: bool default: false
--trace-migration (trace object migration)
type: bool default: false
--trace-generalization (trace map generalization)
type: bool default: false
--trace-heap-broker-verbose (trace the heap broker verbosely (all reports))
type: bool default: false
--trace-turbo (trace generated TurboFan IR)
type: bool default: false
--trace-turbo-inlining (trace TurboFan inlining)
type: bool default: false
--trace-gc (print one trace line following each garbage collection)
type: bool default: false
--trace-opt-verbose (extra verbose compilation tracing)
type: bool default: false
--trace-deopt (trace optimize function deoptimization)
type: bool default: false
--trace-ic (trace inline cache state transitions for tools/ic-processor)
type: bool default: false
That's not all, just ones i've found really useful at the beginning.
gclinet or gclient ??
only gclient exists in ~/depot_tools