{"action":"created","issue":{"url":"https://api.github.com/repos/WebAssembly/design/issues/732","repository_url":"https://api.github.com/repos/WebAssembly/design","labels_url":"https://api.github.com/repos/WebAssembly/design/issues/732/labels{/name}","comments_url":"https://api.github.com/repos/WebAssembly/design/issues/732/comments","events_url":"https://api.github.com/repos/WebAssembly/design/issues/732/events","html_url":"https://github.com/WebAssembly/design/issues/732","id":167616426,"number":732,"title":"Remove mutable globals?","user":{"login":"AndrewScheidecker","id":2691804,"avatar_url":"https://avatars.githubusercontent.com/u/2691804?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewScheidecker","html_url":"https://github.com/AndrewScheidecker","followers_url":"https://api.github.com/users/AndrewScheidecker/followers","following_url":"https://api.github.com/users/AndrewScheidecker/following{/other_user}","gists_url":"https://api.github.com/users/AndrewScheidecker/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewScheidecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewScheidecker/subscriptions","organizations_url":"https://api.github.com/users/AndrewScheidecker/orgs","repos_url":"https://api.github.com/users/AndrewScheidecker/repos","events_url":"https://api.github.com/users/AndrewScheidecker/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewScheidecker/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-26T14:08:18Z","updated_at":"2016-07-26T15:28:28Z","closed_at":null,"body":"I think we should limit globals to immutable values, and translate all mutable globals to immutable addresses into linear memory.\r\n\r\nThis makes the global functionality entirely orthogonal to the functionality of loads and stores; it supports any data that can be stored in memory: e.g. 8- and 16-bit signed and unsigned integers, structs, arrays; it ensures that future threading support is orthogonal to globals; it means simpler code generation for global variables; and it simplifies WebAssembly runtimes.\r\n\r\nThe argument for mutable variables seems to be dependent on the future addition of GC reference types, since those types could not be stored in linear memory. However, such an addition remains speculative, and would have a large impact on how globals are implemented; not to mention other parts of a WebAssembly runtime! I believe it would be best to start with immutable globals only, and only add mutable globals when necessary to support types that can't be stored in aliased memory.\r\n\r\nIf mutable variables are removed, then it's also no longer necessary to support the explicit declaration of globals. Instead, immutable globals could be introduced by other declarations: e.g. relocatable data segments and imports.\r\n\r\n```\r\n(segment $global_var_addr \"\\00\")\r\n(export $global_var_addr ...)\r\n(import $imported_global_addr ...)\r\n...\r\n(i32.store8\r\n    (immutable $global_var_addr)\r\n    (i32.load16_s offset=100 (immutable $imported_global_addr))\r\n    )\r\n```"},"comment":{"url":"https://api.github.com/repos/WebAssembly/design/issues/comments/235304865","html_url":"https://github.com/WebAssembly/design/issues/732#issuecomment-235304865","issue_url":"https://api.github.com/repos/WebAssembly/design/issues/732","id":235304865,"user":{"login":"titzer","id":12184276,"avatar_url":"https://avatars.githubusercontent.com/u/12184276?v=3","gravatar_id":"","url":"https://api.github.com/users/titzer","html_url":"https://github.com/titzer","followers_url":"https://api.github.com/users/titzer/followers","following_url":"https://api.github.com/users/titzer/following{/other_user}","gists_url":"https://api.github.com/users/titzer/gists{/gist_id}","starred_url":"https://api.github.com/users/titzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/titzer/subscriptions","organizations_url":"https://api.github.com/users/titzer/orgs","repos_url":"https://api.github.com/users/titzer/repos","events_url":"https://api.github.com/users/titzer/events{/privacy}","received_events_url":"https://api.github.com/users/titzer/received_events","type":"User","site_admin":false},"created_at":"2016-07-26T15:28:28Z","updated_at":"2016-07-26T15:28:28Z","body":"Mutable globals have the advantage that they cannot be aliased to the linear memory. When WASM gets threads, we'll want to add thread-local storage (TLS), and it would complete a natural hierarchy of storage locations: local to a function, local to a thread, and global. It makes sense to me that these don't alias each other and all use the same type system."}}
{"actor":{"display_login":"titzer"}}