Created
April 14, 2016 07:23
-
-
Save mraleph/ad0f453ddb97ba3f26e2c1395e7e97b0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// d8 --allow-natives-syntax --trace-opt --trace-deopt test.js | |
var o = { x: 0, y: 0 }; | |
print(%HasFastProperties(o)); // => true | |
Object.setPrototypeOf(o, { random: 'stuff', stuff: function() { } }); | |
print(%HasFastProperties(o)); // => true | |
function foo (o) { | |
return o.x; | |
} | |
function bar (o) { | |
return o.random; | |
} | |
function baz (o) { | |
return o.stuff(); | |
} | |
function opt(f, o) { | |
f(o); f(o); f(o); | |
%OptimizeFunctionOnNextCall(f); | |
f(o); | |
} | |
opt(foo, o); | |
opt(bar, o); | |
opt(baz, o); | |
// No deoptimization below | |
print('{{{') | |
Object.setPrototypeOf(o, { emptiness: 'is form', form: 'is emptiness', stuff: function ( ) { } }); | |
print('}}}') | |
print(%HasFastProperties(o)); // => true | |
// Eager deopts in each call below | |
foo(o); | |
bar(o); | |
baz(o); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment