-
Notifications
You must be signed in to change notification settings - Fork 695
call_indirect #488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Wasm is a primitive language and it does not deal with higher level language objects and abstractions directly just as hardware generally does not, well the x86 and ARM and SPARC and PPC etc. For a dynamic language the call will need to pass arguments on a stack implemented in the linear memory and pass the stack pointer(s) in the wasm arguments. The higher level language compiler might be able map some known fixed arguments to wasm fixed arguments. |
Concerning 1., What WebAssembly calls modules may differ from what "modules" mean in other contexts. A WebAssembly module roughly corresponds with a fully linked executable file, including any static libraries linked into it. Also, the scope of a Lastly, there is also an open design issue about whether the semantic distinction of calling a function in another instance should be dropped: #421 Concerning 2., Higher-level language types will need to be lowered when translated in to WebAssembly. Concerning 3., C++ compilers fully resolve templates at compile time before producing wasm, so when wasm code is produced, instantiated function templates just look like regular statically resolved functions with statically typed arguments. Generics in languages that use dynamic resolution will need to be lowered into primitive operations and types in wasm. |
Well, this
raises other issues. Nearly every web site has at least (!) one copy of jquery in it. The browser mitigates the effect of this by caching. However, if a webasm program is expected to be fully linked prior to loading then there is likely to be a lot of redundant loading together with reduced caching effectiveness. |
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. |
@fmccabe Dynamic linking seems to be a matter still under discussion. The wasm function arguments are 'properly typed' and verified from the perspective that is currently intended. It's not intended to 'support verification of code' at the level of implicitly checking ranges on integers or even declaring they are signed or unsigned. A higher level language could emit explicit range checks to add such checking, and I have been exploring taking advantage of this by supporting type derivation in the deployment language but there has been no support for this - not even improving it in JS for asm.js! I would support adding operations for improving the encoding efficiency and readability of range checks that a higher level language might emit for it's own safety, and this could be justified in terms of improving the encoding efficiency of very common patterns. At the text source code level these might be cleaner to add as declared types for function arguments and perhaps a function result type and types for expression values and function and block local variables. |
We considered several alternatives for indirect calls, including adding a I think we will want to have fully statically typed function references in One big advantage of the current scheme is that the indirect call table can On Wed, Dec 2, 2015 at 8:22 PM, Frank McCabe [email protected]
|
FWIW, most of this is violated by after-
|
@kg Are there plans to make "after-main" dynamic linking work differently than regular dynamic linking in a way that affects what |
Closing, as the original questions in this issue appear to be answered. If there are further questions or concerns, please file a new issue. Thanks! |
There appear to be a deficiency with the current thinking around call_indirect:
The problems here are three-fold (at least):
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.BTW, this applies to C/C++ as well as to functional languages.
Given 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.
An 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).
The text was updated successfully, but these errors were encountered: