Adding a property to one function, but not all functions, causes Not optimized flag on function containing Function.prototype.apply
.
"V8 only recognizes monomorphic .apply call-sites" - @mraleph
See example.js
fix.js
)node --trace_opt --trace_deopt example.js | grep "failed to optimize dispatch"
jspm install
http-server # open http://localhost:8080/
xxxxxxxxxx
<html lang="en">
<head>
<meta charset="utf-8">
<title>EventsSpeedTests</title>
<style>
button {
padding: .5em 1em;
display: block;
text-align: center;
margin-top: 5px;
width: 200px;
}
</style>
</head>
<body id="home">
<h1>De-opt Test</h1>
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
addButton('example');
addButton('example2');
addButton('fix');
function addButton(name) {
var element = document.createElement("button");
element.innerHTML = name;
element.onclick=function(){
console.log('start',name);
var start = new Date().getTime();
System.import('./'+name+'.js').then(function () {
var time = new Date().getTime() - start;
console.log('end',name, time, 'ms');
});
}
document.body.appendChild(element);
}
</script>
</body>
</html>