Last modified: 2014-11-05 19:40:20 UTC
To reproduce: - Navigate to an article - Open Chrome's Developer Tools - Click 'Profiles' - Select 'Collect JavaScript CPU Profile' - Click 'Start' - Click 'Edit [beta]' - Wait for VisualEditor to finish loading - Click 'Stop' Result: Both oo.Factory.create or oo.EventEmitter.emit are flagged by the profiler with the warning: "Not optimized: Inlining bailed out." To investigate, I recommend reading <https://github.com/GoogleChrome/devtools-docs/issues/53> v8 comes with a 'd8' executable that can be used for getting some performance debug info from v8. If you can craft a file that utilizes these functions without depending on the DOM API, you can try running it with: > d8 --trace-opt --trace-bailout some-js-file.js
For oo.Factory.create, my version of Chrome tells me "Not optimized: Bad value context for arguments value" which seems to be a consequence of doing args = Array.prototype.slice.call( arguments, 1 ); . I don't really see a way around that, unless there's some way of making the arguments list a real array that V8 is able to optimize. For oo.EventEmitter.emit it does say "Inlining bailed out". I'm installing d8 now to investigate. I saw a bunch of other "not optimized" warnings too, but most of those seem to be about try-catch statements. The only other one that jumped out at me was in oo.copy: "ForInStatement is not fast case". Will investigate that too.
EventEmitter.emit also seems to be because of arguments. I checked, though, and there's very little "self" time spent in EventEmitter.emit and Factory.create: 25ms and 53ms respectively for Obama. But I'll see what that drops to after optimizing them.