{"action":"created","issue":{"url":"https://api.github.com/repos/WebAssembly/binaryen/issues/1818","repository_url":"https://api.github.com/repos/WebAssembly/binaryen","labels_url":"https://api.github.com/repos/WebAssembly/binaryen/issues/1818/labels{/name}","comments_url":"https://api.github.com/repos/WebAssembly/binaryen/issues/1818/comments","events_url":"https://api.github.com/repos/WebAssembly/binaryen/issues/1818/events","html_url":"https://github.com/WebAssembly/binaryen/issues/1818","id":389900227,"node_id":"MDU6SXNzdWUzODk5MDAyMjc=","number":1818,"title":"wasm backend stack pointer setup","user":{"login":"kripken","id":173661,"node_id":"MDQ6VXNlcjE3MzY2MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/173661?v=4","gravatar_id":"","url":"https://api.github.com/users/kripken","html_url":"https://github.com/kripken","followers_url":"https://api.github.com/users/kripken/followers","following_url":"https://api.github.com/users/kripken/following{/other_user}","gists_url":"https://api.github.com/users/kripken/gists{/gist_id}","starred_url":"https://api.github.com/users/kripken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kripken/subscriptions","organizations_url":"https://api.github.com/users/kripken/orgs","repos_url":"https://api.github.com/users/kripken/repos","events_url":"https://api.github.com/users/kripken/events{/privacy}","received_events_url":"https://api.github.com/users/kripken/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-11T18:41:00Z","updated_at":"2018-12-11T19:05:59Z","closed_at":null,"author_association":"MEMBER","body":"Right now the wasm backend stack pointer is a mutable global, and the emscripten JS initializes it by calling `stackRestore`. As a result, that function is kept alive, which adds a tiny amount of code size. Also a tiny amount of work (js=>wasm call) on the startup path.\r\n\r\nAlternatively, we could import the value (even without mutable global imports, by adding another import like asm2wasm does), say `\"env.__stack_init\"`? `wasm-emscripten-finalize` could do that.\r\n\r\nThoughts? I'm not entirely sure of the considerations that went into the current model, so maybe I'm missing something here (so asking first instead of opening a PR).\r\n\r\ncc @dschuff @jgravelle-google @sbc100 "},"comment":{"url":"https://api.github.com/repos/WebAssembly/binaryen/issues/comments/446322434","html_url":"https://github.com/WebAssembly/binaryen/issues/1818#issuecomment-446322434","issue_url":"https://api.github.com/repos/WebAssembly/binaryen/issues/1818","id":446322434,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NjMyMjQzNA==","user":{"login":"jgravelle-google","id":20847303,"node_id":"MDQ6VXNlcjIwODQ3MzAz","avatar_url":"https://avatars3.githubusercontent.com/u/20847303?v=4","gravatar_id":"","url":"https://api.github.com/users/jgravelle-google","html_url":"https://github.com/jgravelle-google","followers_url":"https://api.github.com/users/jgravelle-google/followers","following_url":"https://api.github.com/users/jgravelle-google/following{/other_user}","gists_url":"https://api.github.com/users/jgravelle-google/gists{/gist_id}","starred_url":"https://api.github.com/users/jgravelle-google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgravelle-google/subscriptions","organizations_url":"https://api.github.com/users/jgravelle-google/orgs","repos_url":"https://api.github.com/users/jgravelle-google/repos","events_url":"https://api.github.com/users/jgravelle-google/events{/privacy}","received_events_url":"https://api.github.com/users/jgravelle-google/received_events","type":"User","site_admin":false},"created_at":"2018-12-11T19:05:59Z","updated_at":"2018-12-11T19:05:59Z","author_association":"CONTRIBUTOR","body":"In general `wasm-emscripten-finalize` lets us change LLVM output to match emscripten's expectations, meaning it frees us to make changes that are convenient for one without worrying about breaking the other.\r\nSo: the only reasons I'm aware of that we even generate the stackSave/stackRestore functions is for emscripten interop. If we want to change how that's done, there's no constraint on it other than emscripten library code.\r\n\r\nConsiderations:\r\nstackSave/stackRestore get called by emscripten library js code in general at runtime, so we need to generate it anyway in wasm-emscripten-finalize to metaDCE later as far as I know.\r\nThey definitely get called in dynamic libraries today because we can't export mutable globals.\r\n\r\nBut, I'd think that changing only the initially-set stack position shouldn't affect anything else, and should be pretty straightforward. Sgtm"}}
{"actor":{"display_login":"jgravelle-google"}}