{"action":"opened","issue":{"url":"https://api.github.com/repos/golang/go/issues/29067","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/29067/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/29067/comments","events_url":"https://api.github.com/repos/golang/go/issues/29067/events","html_url":"https://github.com/golang/go/issues/29067","id":386635771,"node_id":"MDU6SXNzdWUzODY2MzU3NzE=","number":29067,"title":"Minimize morestack calls footprint","user":{"login":"CAFxX","id":408018,"node_id":"MDQ6VXNlcjQwODAxOA==","avatar_url":"https://avatars0.githubusercontent.com/u/408018?v=4","gravatar_id":"","url":"https://api.github.com/users/CAFxX","html_url":"https://github.com/CAFxX","followers_url":"https://api.github.com/users/CAFxX/followers","following_url":"https://api.github.com/users/CAFxX/following{/other_user}","gists_url":"https://api.github.com/users/CAFxX/gists{/gist_id}","starred_url":"https://api.github.com/users/CAFxX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CAFxX/subscriptions","organizations_url":"https://api.github.com/users/CAFxX/orgs","repos_url":"https://api.github.com/users/CAFxX/repos","events_url":"https://api.github.com/users/CAFxX/events{/privacy}","received_events_url":"https://api.github.com/users/CAFxX/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-03T02:31:51Z","updated_at":"2018-12-03T02:31:51Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"This is more of a small papercut idea than a real issue, but every time I go through the disassembled output of objdump it comes back to mind, so I'm going to drop it here.\r\n\r\nCurrently the morestack check is laid out as follows:\r\n\r\nfunction entry point:\r\n  check if enough stack\r\n  if not enough stack, jump to morestack block # JMP1\r\n  ...function body...\r\nmorestack block:\r\n  call morestack\r\n  jump to function entry point # JMP2\r\n\r\nif it was instead laid out like this:\r\n\r\nmorestack block:\r\n  call morestack\r\nfunction entry point:\r\n  check if enough stack\r\n  if not enough stack, jump to morestack block\r\n  ...function body...\r\n\r\nwe have one less jump (JMP2) and, more importantly, JMP1 can always use the more compact rel8 variant. The morestack block, in this case, would be placed in the padding between this and the previous function (because the morestack block of the previous function would have been moved as well, this should not significantly impact the overall amount of padding used)\r\n\r\nFor small functions (i.e. functions where rel8 is already used in both jumps) this would save 2 bytes per function, for functions where rel32 is used it would save 10 bytes per function. From a quick check there are ~1800 small functions and ~5000 big functions using morestack in the 1.11.2 windows compiler. This means that text size could decrease by ~86KB.\r\n\r\nLooking forward to when per-function metadata will make it possible to mostly eliminate morestack calls, this could be further extended to have multiple entry points:\r\n\r\nmorestack block:\r\n  call morestack\r\nfunction entry point:\r\n  check if enough stack\r\n  if not enough stack, jump to morestack block\r\nfunction entry point no-morestack:\r\n  ...function body...\r\n\r\nI'm not knowledgeable about the linker, so I don't really know how workable these two ideas are."}}
{"actor":{"display_login":"CAFxX"}}