{"action":"opened","issue":{"url":"https://api.github.com/repos/WebAssembly/binaryen/issues/667","repository_url":"https://api.github.com/repos/WebAssembly/binaryen","labels_url":"https://api.github.com/repos/WebAssembly/binaryen/issues/667/labels{/name}","comments_url":"https://api.github.com/repos/WebAssembly/binaryen/issues/667/comments","events_url":"https://api.github.com/repos/WebAssembly/binaryen/issues/667/events","html_url":"https://github.com/WebAssembly/binaryen/issues/667","id":170638338,"number":667,"title":"asm2wasm translates modulus operator to import call instead of i32.rem_s","user":{"login":"ceautery","id":2135631,"avatar_url":"https://avatars.githubusercontent.com/u/2135631?v=3","gravatar_id":"","url":"https://api.github.com/users/ceautery","html_url":"https://github.com/ceautery","followers_url":"https://api.github.com/users/ceautery/followers","following_url":"https://api.github.com/users/ceautery/following{/other_user}","gists_url":"https://api.github.com/users/ceautery/gists{/gist_id}","starred_url":"https://api.github.com/users/ceautery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceautery/subscriptions","organizations_url":"https://api.github.com/users/ceautery/orgs","repos_url":"https://api.github.com/users/ceautery/repos","events_url":"https://api.github.com/users/ceautery/events{/privacy}","received_events_url":"https://api.github.com/users/ceautery/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-11T12:52:07Z","updated_at":"2016-08-11T12:52:07Z","closed_at":null,"body":"The asm.js line:\r\n\r\n    if (val % i == 0) return 0;\r\n\r\n...where \"val\" and \"i\" are both ints, gets translated as an external import in the header and a call to that import:\r\n\r\n    (type $FUNCSIG$iii (func (param i32 i32) (result i32)))\r\n    (import $i32s-rem \"asm2wasm\" \"i32s-rem\" (param i32 i32) (result i32))\r\n\r\nand then\r\n\r\n    (if\r\n      (i32.eq\r\n        (call_import $i32s-rem\r\n          (get_local $0)\r\n          (get_local $4)\r\n        )\r\n        (i32.const 0)\r\n      )\r\n      (return\r\n        (i32.const 0)\r\n      )\r\n    )\r\n\r\nThis compiles fine with wasm-as, but fails in the browser with an instantiation error of\r\n\r\n    Import #0 module=\"asm2wasm\" function=\"i32s-rem\" error: FFI is not an object\r\n\r\nIf I edit the asm2wasm output to remove the imports and swap the call_import line with:\r\n\r\n    (i32.rem_s\r\n\r\n...wasm-as compiles it fine, and the module works as expected in the browser. Can asm2wasm use the built-in S expression i32.rem_s for integer modulus operations, or is there an overriding reason to stick with the external call? If so, how do I reference the import from JavaScript?\r\n\r\nThanks!"}}
{"actor":{"display_login":"ceautery"}}