WASM is meant to be executed by general purpose computers. How does the low level WASM get converted to a form that the EOS virtual machine can understand?
3 Answers
WebAssembly is indeed the instruction format that the virtual machine understands.
The actual interaction between the eos library and the wasm binary is done through WebAssembly modules. Every contract thus has to export an apply function, which serves as the entrypoint. It can also import functions to interact with the eos environment. A small subset of these functions are listed here.
Finally I'm pretty sure the eos virtual machine does not support the webassembly float types.
-
Not enough reputation to add a comment to @wanheda's so let me note it here: EOS WASM does support floating point though only through a software library so as to avoid inconsistencies between the different existing implementations.– TianaCommented Jan 17, 2019 at 18:40
"EOS virtual machine" == WAVM or binaryen, which is a WASM-specific VM.
-
-
here is github.com/go-interpreter/wagon, a standalone VM for interpreting WASM, which is easy to understand compared to binaryen(github.com/WebAssembly/binaryen) or WAVM(github.com/AndrewScheidecker/WAVM). You can see that wagon is a classic stack-based VM, who provides a stack, memory, and some instructions. Cause Wasm is well formed after compiling by AOT tools, When interpreting, A PC travels wasm bytecode, get the operators and run the instructions(actually binding a function), get the result and push into the stack. Commented Aug 17, 2018 at 15:25
-
Until reaching the end of the bytecode, you can get the result. Interpreting is simple compared to designing the syntax in some way. I am not sure this is what you want to know. Commented Aug 17, 2018 at 15:26