{"action":"created","issue":{"url":"https://api.github.com/repos/systemjs/systemjs/issues/1671","repository_url":"https://api.github.com/repos/systemjs/systemjs","labels_url":"https://api.github.com/repos/systemjs/systemjs/issues/1671/labels{/name}","comments_url":"https://api.github.com/repos/systemjs/systemjs/issues/1671/comments","events_url":"https://api.github.com/repos/systemjs/systemjs/issues/1671/events","html_url":"https://github.com/systemjs/systemjs/issues/1671","id":227635526,"number":1671,"title":"WASM memory registration","user":{"login":"guybedford","id":598730,"avatar_url":"https://avatars2.githubusercontent.com/u/598730?v=3","gravatar_id":"","url":"https://api.github.com/users/guybedford","html_url":"https://github.com/guybedford","followers_url":"https://api.github.com/users/guybedford/followers","following_url":"https://api.github.com/users/guybedford/following{/other_user}","gists_url":"https://api.github.com/users/guybedford/gists{/gist_id}","starred_url":"https://api.github.com/users/guybedford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guybedford/subscriptions","organizations_url":"https://api.github.com/users/guybedford/orgs","repos_url":"https://api.github.com/users/guybedford/repos","events_url":"https://api.github.com/users/guybedford/events{/privacy}","received_events_url":"https://api.github.com/users/guybedford/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2017-05-10T10:31:23Z","updated_at":"2017-05-25T15:21:08Z","closed_at":null,"body":"When using an ES-modules-style linking with WASM there is a need for more than just blind ES linking, but an actual memory referencing protocol to be able to handle the standard use cases.\r\n\r\nBy default, LLVM compilation of Web Assembly (or the s2wast transform?) will make the memory exported, and will load external functions from an `env` module.\r\n\r\nThe idea here for SystemJS is to check if there is an `env` import for the WASM module being loaded, and if so, to have that `env` module generated at link time to bind to the memory via something like:\r\n\r\n```js\r\nlet envModule = generateWasmEnv(wasmMemory);\r\n```\r\n\r\nThis core env wasm handler to be customized via `System.config({ wasmEnv: 'x.js' })`.\r\n\r\nAn example WASM environment loader might look like:\r\n\r\n```js\r\nexport default function generateWasmEnv (wasmMemory) {\r\n  return {\r\n    malloc (size) {\r\n      // ... malloc implementation bound to memory now ...\r\n    },\r\n    // ... stdlib helpers ...\r\n  };\r\n}\r\n```\r\n\r\nIt may even be possible to read the imports and provide the list of env imports specifically to the generation function.\r\n\r\nWhere the WASM module need only call `malloc(size)` to get the memory automatically referenced by the bound env file call.\r\n\r\nSuch a feature should be opt-in only as it is highly experimental.\r\n\r\n//cc @lukewagner @yuridelendik would value your feedback / experience / suggestions here. And also to know if this is completely crazy or something that might be worth prototyping here."},"comment":{"url":"https://api.github.com/repos/systemjs/systemjs/issues/comments/304037918","html_url":"https://github.com/systemjs/systemjs/issues/1671#issuecomment-304037918","issue_url":"https://api.github.com/repos/systemjs/systemjs/issues/1671","id":304037918,"user":{"login":"guybedford","id":598730,"avatar_url":"https://avatars2.githubusercontent.com/u/598730?v=3","gravatar_id":"","url":"https://api.github.com/users/guybedford","html_url":"https://github.com/guybedford","followers_url":"https://api.github.com/users/guybedford/followers","following_url":"https://api.github.com/users/guybedford/following{/other_user}","gists_url":"https://api.github.com/users/guybedford/gists{/gist_id}","starred_url":"https://api.github.com/users/guybedford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guybedford/subscriptions","organizations_url":"https://api.github.com/users/guybedford/orgs","repos_url":"https://api.github.com/users/guybedford/repos","events_url":"https://api.github.com/users/guybedford/events{/privacy}","received_events_url":"https://api.github.com/users/guybedford/received_events","type":"User","site_admin":false},"created_at":"2017-05-25T15:21:07Z","updated_at":"2017-05-25T15:21:07Z","body":"The thing I have reservations about for that is that for multiple other\nmodules to share that same memory, they need to then know to offset their\ndata sections and coordinate on that right? It feels like it might be\neasier if such coordination wouldn't be necessary?\nOn Thu, 25 May 2017 at 17:14, Luke Wagner <notifications@github.com> wrote:\n\n> Sorry if I missed this, but is there any reason that mem.wasm can't itself\n> define and export the Memory?\n>\n> —\n> You are receiving this because you modified the open/close state.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/systemjs/systemjs/issues/1671#issuecomment-304036208>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/AAkiygU-oYLqGwLguQfokXWGNiWsyyKKks5r9ZrjgaJpZM4NWePv>\n> .\n>\n"}}
{"actor":{"display_login":"guybedford"}}