{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/io.js/issues/1752","labels_url":"https://api.github.com/repos/nodejs/io.js/issues/1752/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/io.js/issues/1752/comments","events_url":"https://api.github.com/repos/nodejs/io.js/issues/1752/events","html_url":"https://github.com/nodejs/io.js/pull/1752","id":78730891,"number":1752,"title":"lib: Prevent leaking arguments in several places.","user":{"login":"ChALkeR","id":291301,"avatar_url":"https://avatars.githubusercontent.com/u/291301?v=3","gravatar_id":"","url":"https://api.github.com/users/ChALkeR","html_url":"https://github.com/ChALkeR","followers_url":"https://api.github.com/users/ChALkeR/followers","following_url":"https://api.github.com/users/ChALkeR/following{/other_user}","gists_url":"https://api.github.com/users/ChALkeR/gists{/gist_id}","starred_url":"https://api.github.com/users/ChALkeR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChALkeR/subscriptions","organizations_url":"https://api.github.com/users/ChALkeR/orgs","repos_url":"https://api.github.com/users/ChALkeR/repos","events_url":"https://api.github.com/users/ChALkeR/events{/privacy}","received_events_url":"https://api.github.com/users/ChALkeR/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2015-05-20T22:44:55Z","updated_at":"2015-05-26T23:59:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nodejs/io.js/pulls/1752","html_url":"https://github.com/nodejs/io.js/pull/1752","diff_url":"https://github.com/nodejs/io.js/pull/1752.diff","patch_url":"https://github.com/nodejs/io.js/pull/1752.patch"},"body":"This prevents leaking arguments in several places.\r\n\r\n**Not yet final, I will probably update this with more patches, waiting for comments.**\r\n\r\nCurrently the three fixed places are `util.format` (called for example by `console.log`), `console.assert`, and `path.win32.join`.\r\n\r\nIn `path.win32.join` this PR changes the stack of the `TypeError('Arguments to path.join must be strings')`, removing the top `at f (path.js:190:13)` and `at Object.filter (native)` so now it is similar to the stack in `path.posix.join`.\r\n\r\n`util.format` results:\r\n* ~50% speedup on `util.format('abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc1234567890')` (16700000 ⇒ 32900000 ops/second).\r\n* ~8% speedup on `util.format({a:2,b:10,c:10},20,'d')` (50000 ⇒ 54000 ops/second).\r\n* ~28% speedup on `util.format('Hello %s %s',20,'d')` (580000 ⇒ 800000 ops/second).\r\n\r\n`console.assert` results:\r\n* ~27% speedup on common `console.assert(true, 'text')` (2550000 ⇒ 3230000 ops/second).\r\n* ~23% speedup on `console.assert(true)` ( 3000000 ⇒ 3700000 ops/second).\r\n\r\n`path.win32.join` results:\r\n* ~33% speedup on `path.join('a','b','c')` (400000 ⇒ 598000 ops/second).\r\n\r\nSee https://github.com/nodejs/io.js/pull/1749#discussion_r30743809, https://gist.github.com/Fishrock123/98c35a0c745cb59d7496 and https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments"},"comment":{"url":"https://api.github.com/repos/nodejs/io.js/issues/comments/105700508","html_url":"https://github.com/nodejs/io.js/pull/1752#issuecomment-105700508","issue_url":"https://api.github.com/repos/nodejs/io.js/issues/1752","id":105700508,"user":{"login":"ChALkeR","id":291301,"avatar_url":"https://avatars.githubusercontent.com/u/291301?v=3","gravatar_id":"","url":"https://api.github.com/users/ChALkeR","html_url":"https://github.com/ChALkeR","followers_url":"https://api.github.com/users/ChALkeR/followers","following_url":"https://api.github.com/users/ChALkeR/following{/other_user}","gists_url":"https://api.github.com/users/ChALkeR/gists{/gist_id}","starred_url":"https://api.github.com/users/ChALkeR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChALkeR/subscriptions","organizations_url":"https://api.github.com/users/ChALkeR/orgs","repos_url":"https://api.github.com/users/ChALkeR/repos","events_url":"https://api.github.com/users/ChALkeR/events{/privacy}","received_events_url":"https://api.github.com/users/ChALkeR/received_events","type":"User","site_admin":false},"created_at":"2015-05-26T23:59:49Z","updated_at":"2015-05-26T23:59:49Z","body":"@trevnorris `arguments` is not an array, also it introduces a deopt if you do anything to it except taking `arguments.length` and accessing `arguments[i]` where `0 <= i < arguments.length`. This is why manually copying arguments to an array and passing that array is faster than passing the arguments object.\r\n\r\n«On par with `arguments`» is not good enough. Afaik, rest params are deoptimized now. Also, I am not sure what is the v8 version requirements for them to work without issues. And they are behind a flag."}}