Skip to content

Instantly share code, notes, and snippets.

@phpnode

phpnode/deopt.js Secret

Last active August 29, 2015 14:16
Show Gist options
  • Save phpnode/6691e9d3171e464e2e21 to your computer and use it in GitHub Desktop.
Save phpnode/6691e9d3171e464e2e21 to your computer and use it in GitHub Desktop.
/*
cat deopt.js | node --trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces --redirect-code-traces-to=code.asm --allow-natives-syntax --print-opt-code
*/
function createObj () {
return {
"1": 1,
"2": 2,
"3": 3,
"a": 4,
"b": 5,
"c": 6
};
}
function computed (prop) {
var foo = prop.valueOf();
return createObj()[foo];
}
function run () {
var acc = 0;
acc += computed(1);
acc += computed(2);
acc += computed(3);
acc += computed("a");
acc += computed("b");
acc += computed("c");
acc += computed(1);
acc += computed(2);
acc += computed(3);
acc += computed("a");
acc += computed("b");
acc += computed("c");
return acc;
}
for (var i = 0; i < 10000; i++) {
run();
}
console.log(run());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment