{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/1410","repository_url":"https://api.github.com/repos/Microsoft/ChakraCore","labels_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/1410/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/1410/comments","events_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/1410/events","html_url":"https://github.com/Microsoft/ChakraCore/issues/1410","id":170302154,"number":1410,"title":"An idea for tail calls","user":{"login":"DemiMarie","id":6395399,"avatar_url":"https://avatars.githubusercontent.com/u/6395399?v=3","gravatar_id":"","url":"https://api.github.com/users/DemiMarie","html_url":"https://github.com/DemiMarie","followers_url":"https://api.github.com/users/DemiMarie/followers","following_url":"https://api.github.com/users/DemiMarie/following{/other_user}","gists_url":"https://api.github.com/users/DemiMarie/gists{/gist_id}","starred_url":"https://api.github.com/users/DemiMarie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemiMarie/subscriptions","organizations_url":"https://api.github.com/users/DemiMarie/orgs","repos_url":"https://api.github.com/users/DemiMarie/repos","events_url":"https://api.github.com/users/DemiMarie/events{/privacy}","received_events_url":"https://api.github.com/users/DemiMarie/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/ChakraCore/labels/Discussion","name":"Discussion","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-10T00:27:23Z","updated_at":"2016-08-22T21:46:02Z","closed_at":null,"body":"I think ChakraCore could implement tail calls without an undue performance penalty by using explicit frame pointers.  As I understand it, LLVM _does_ support proper tail calls on Windows x64 (and does so even with separate compilation – so LLVM cannot just preallocate space in the caller, since it doesn't know the amount of stack space the callee will need).  Therefore, LLVM must be able to emit proper unwind info, and I suspect they use a frame pointer for this case (the so-called `fastcall` LLVM calling convention)."},"comment":{"url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/comments/241561238","html_url":"https://github.com/Microsoft/ChakraCore/issues/1410#issuecomment-241561238","issue_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/1410","id":241561238,"user":{"login":"LouisLaf","id":12550583,"avatar_url":"https://avatars.githubusercontent.com/u/12550583?v=3","gravatar_id":"","url":"https://api.github.com/users/LouisLaf","html_url":"https://github.com/LouisLaf","followers_url":"https://api.github.com/users/LouisLaf/followers","following_url":"https://api.github.com/users/LouisLaf/following{/other_user}","gists_url":"https://api.github.com/users/LouisLaf/gists{/gist_id}","starred_url":"https://api.github.com/users/LouisLaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LouisLaf/subscriptions","organizations_url":"https://api.github.com/users/LouisLaf/orgs","repos_url":"https://api.github.com/users/LouisLaf/repos","events_url":"https://api.github.com/users/LouisLaf/events{/privacy}","received_events_url":"https://api.github.com/users/LouisLaf/received_events","type":"User","site_admin":false},"created_at":"2016-08-22T21:46:02Z","updated_at":"2016-08-22T21:46:02Z","body":"Chakra already does use an explicit frame pointer, but this is not really the issue.  The main issue is that all function in JavaScript have a variable argument list (arguments are optional and passing extra is ok).  LLVM does not do tail call if the caller has a variable argument list.\r\n\r\nWithout an variable argument list, a compiler can emit code to deal with the specific situation: same number of in/out args, less out args or more out args.  It can also decide to only handle some of these situations.  With variable argument list, the JIT needs to emit code to handle all of these decisions, and dynamically pick the right code path at runtime.\r\n\r\nCompilers also use a \"caller-cleanup\" calling convention for variable argument list calls, since the caller statically knows the amount of stack space to cleanup after the call.  For tail call, you need to use a callee-cleanup convention since the original caller does not know the amount of stack to cleanup for the tail call callee.\r\n\r\nOn Windows x64, a fixed-stack calling convention is used makes it really hard to support these complex stack manipulation without requiring extra frames (which defeats the whole purpose) or some pretty severe performance penalty."}}
{"actor":{"display_login":"LouisLaf"}}