Last active
August 29, 2015 14:18
-
-
Save mraleph/141f0ed76bd24fb28243 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
function bar(x) { | |
try { // just to prevent inlining | |
return x; | |
} catch (e) { } | |
} | |
function foo(o) { | |
var sum = 0; | |
for (var i = 0; i < 10; i++) { | |
sum += bar(o.x); /* o.x will not be hoisted out of the loop */ | |
/* but corresponding map check would be *removed* */ | |
/* so V8 partially understands immutability of the hidden class of o */ | |
} | |
return sum; | |
} | |
var o = Object.freeze({x: 10}); | |
for (var j = 0 ; j < 10000; j++) { | |
foo(o); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment