Install depot_tools
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ export PATH=`pwd`/depot_tools:"$PATH"
Build v8
$ fetch v8
$ cd v8
$ make x64.debug
Run d8
$ ./out/x64.debug/d8
You can alias d8 in you .bash_profile
by adding the following line to it:
alias d8=/path/to/v8/repo/out/x64.debug/d8
Create a file classes.js
with the following content
var a = {}
a.x = 8;
a.y = 8;
var b = {}
b.x = 3;
b.y = 9;
print(%HaveSameMap(a, b)); // true
a.z = 1;
print(%HaveSameMap(a, b)); // false
Run it via d8 --allow_natives_syntax classes.js
.
Check for optimization and deoptimization d8 --traceopt --trace-deopt twice.js
function twice( a ) {
return a + a;
}
var i = 0;
while (i++ < 1000000) {
twice(4);
if (i % 10000 == 0) {
twice('a');
}
}