-
-
Save phpnode/6691e9d3171e464e2e21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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