{"action":"created","issue":{"url":"https://api.github.com/repos/WebAssembly/design/issues/488","labels_url":"https://api.github.com/repos/WebAssembly/design/issues/488/labels{/name}","comments_url":"https://api.github.com/repos/WebAssembly/design/issues/488/comments","events_url":"https://api.github.com/repos/WebAssembly/design/issues/488/events","html_url":"https://github.com/WebAssembly/design/issues/488","id":119834338,"number":488,"title":"call_indirect","user":{"login":"fmccabe","id":3654349,"avatar_url":"https://avatars.githubusercontent.com/u/3654349?v=3","gravatar_id":"","url":"https://api.github.com/users/fmccabe","html_url":"https://github.com/fmccabe","followers_url":"https://api.github.com/users/fmccabe/followers","following_url":"https://api.github.com/users/fmccabe/following{/other_user}","gists_url":"https://api.github.com/users/fmccabe/gists{/gist_id}","starred_url":"https://api.github.com/users/fmccabe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fmccabe/subscriptions","organizations_url":"https://api.github.com/users/fmccabe/orgs","repos_url":"https://api.github.com/users/fmccabe/repos","events_url":"https://api.github.com/users/fmccabe/events{/privacy}","received_events_url":"https://api.github.com/users/fmccabe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-12-01T23:41:14Z","updated_at":"2015-12-02T19:21:36Z","closed_at":null,"body":"There appear to be a deficiency with the current thinking around call_indirect:\r\n\r\n>A `call_indirect` specifies the *expected* signature of the target function with\r\nan index into a *signature table* defined by the module. An indirect call to a\r\nfunction with a mismatched signature causes a trap.\r\n\r\nThe problems here are three-fold (at least):\r\n\r\n1. A higher-order function (where the arguments to the function can contain a function, or where the function returns a function) cannot be invoked. The reason is that a `call_indirect` assumes that the function to be called is in the *same* module as the caller. A higher-order function *cannot* know where its argument functions are located.\r\n2. A higher-order function will have a type signature that does not correspond with int32->int32 style types. Its arguments and/or its return type will not be a normal value.\r\n3. In a language with generics (which includes C++), the actual type of a function may not correspond literally with the call site and yet still be perfectly valid. (e.g., a function with type X->X can be invoked with integer arguments, float arguments, even function arguments).\r\n\r\nBTW, this applies to C/C++ as well as to functional languages.\r\n\r\nGiven that the current function table approach is fixed, call_indirect must be extended to allow inter-module calls *where the module of the callee is dynamically determined*.\r\n\r\nAn alternate is to invent something along the lines of the MethodHandle from the JVM. (Except that that also embeds 'free variables' - another issue with call_indirect).\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/WebAssembly/design/issues/comments/161404515","html_url":"https://github.com/WebAssembly/design/issues/488#issuecomment-161404515","issue_url":"https://api.github.com/repos/WebAssembly/design/issues/488","id":161404515,"user":{"login":"fmccabe","id":3654349,"avatar_url":"https://avatars.githubusercontent.com/u/3654349?v=3","gravatar_id":"","url":"https://api.github.com/users/fmccabe","html_url":"https://github.com/fmccabe","followers_url":"https://api.github.com/users/fmccabe/followers","following_url":"https://api.github.com/users/fmccabe/following{/other_user}","gists_url":"https://api.github.com/users/fmccabe/gists{/gist_id}","starred_url":"https://api.github.com/users/fmccabe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fmccabe/subscriptions","organizations_url":"https://api.github.com/users/fmccabe/orgs","repos_url":"https://api.github.com/users/fmccabe/repos","events_url":"https://api.github.com/users/fmccabe/events{/privacy}","received_events_url":"https://api.github.com/users/fmccabe/received_events","type":"User","site_admin":false},"created_at":"2015-12-02T19:21:36Z","updated_at":"2015-12-02T19:21:36Z","body":"Currently, the spec of a function type signature does not permit the arguments to be properly typed. A type signature which states integer or blob does not support verification of code. Given that programs are going to be executed by innocent users I would have thought that code verification should be high on the list of priorities for this group."}}