{"action":"created","issue":{"url":"https://api.github.com/repos/babel/babel/issues/3143","labels_url":"https://api.github.com/repos/babel/babel/issues/3143/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/3143/comments","events_url":"https://api.github.com/repos/babel/babel/issues/3143/events","html_url":"https://github.com/babel/babel/pull/3143","id":120687011,"number":3143,"title":"[babel-plugin-transform-es2015-parameters][T6774] more opportunities for optimizations","user":{"login":"fabiomcosta","id":28530,"avatar_url":"https://avatars.githubusercontent.com/u/28530?v=3","gravatar_id":"","url":"https://api.github.com/users/fabiomcosta","html_url":"https://github.com/fabiomcosta","followers_url":"https://api.github.com/users/fabiomcosta/followers","following_url":"https://api.github.com/users/fabiomcosta/following{/other_user}","gists_url":"https://api.github.com/users/fabiomcosta/gists{/gist_id}","starred_url":"https://api.github.com/users/fabiomcosta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabiomcosta/subscriptions","organizations_url":"https://api.github.com/users/fabiomcosta/orgs","repos_url":"https://api.github.com/users/fabiomcosta/repos","events_url":"https://api.github.com/users/fabiomcosta/events{/privacy}","received_events_url":"https://api.github.com/users/fabiomcosta/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/babel/babel/labels/optimisation","name":"optimisation","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-12-07T02:42:44Z","updated_at":"2015-12-16T20:56:53Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/babel/babel/pulls/3143","html_url":"https://github.com/babel/babel/pull/3143","diff_url":"https://github.com/babel/babel/pull/3143.diff","patch_url":"https://github.com/babel/babel/pull/3143.patch"},"body":"Babel's arguments transform is pretty cool, it does some optimizations based on a whitelist of checks, but that list could have 2 more items added:\r\n\r\n* arguments.length;\r\n* `<any-function>`.apply(`<any>`, arguments);\r\n\r\nThe second one is a bit controversial because we can't guarantee that `apply` is the native function's function (unless we have flow support, let me know if we do). But most of the time the implemented check is accurate and we should be shooting for the common case not the edge case (IMHO).\r\n\r\nI could confirm that when I add any of those patterns the args array is created, when using http://babeljs.io/repl/.\r\n\r\nThis is based on: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#what-is-safe-arguments-usage\r\nAnd I was also able to see myself functions with these patterns being optimized on V8.\r\n\r\nhttps://phabricator.babeljs.io/T6774"},"comment":{"url":"https://api.github.com/repos/babel/babel/issues/comments/165241827","html_url":"https://github.com/babel/babel/pull/3143#issuecomment-165241827","issue_url":"https://api.github.com/repos/babel/babel/issues/3143","id":165241827,"user":{"login":"amasad","id":587518,"avatar_url":"https://avatars.githubusercontent.com/u/587518?v=3","gravatar_id":"","url":"https://api.github.com/users/amasad","html_url":"https://github.com/amasad","followers_url":"https://api.github.com/users/amasad/followers","following_url":"https://api.github.com/users/amasad/following{/other_user}","gists_url":"https://api.github.com/users/amasad/gists{/gist_id}","starred_url":"https://api.github.com/users/amasad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amasad/subscriptions","organizations_url":"https://api.github.com/users/amasad/orgs","repos_url":"https://api.github.com/users/amasad/repos","events_url":"https://api.github.com/users/amasad/events{/privacy}","received_events_url":"https://api.github.com/users/amasad/received_events","type":"User","site_admin":false},"created_at":"2015-12-16T20:56:53Z","updated_at":"2015-12-16T20:56:53Z","body":">As a note, even the current arguments[<int>] is not safe, if an index that is bigger or equal to the arguments' length is accessed the current function will suffer a deopt (or won't be a candidate for optimization) by V8.\r\n\r\nFixed by @vhf in #2833 and in #3165\r\n\r\n>The option name could be allowRiskyArgumentsOptimizations, but open for suggestions\r\n\r\nSounds good as long as you have a real world use case (are you we going to use it at fb?)."}}