In a recent blog, Daniel Larimer revealed that Eos has added an official WebAssembly interpreter to explain the implementation of the WebAssembly Smart contract, plus the previous compilation execution, with the EOS Smart contract implemented in two ways.
For many programming languages that do not have an intermediate language, there is no option to interpret execution and compile execution, such as traditional C + +, which can only be compiled and compiled directly into an executable binary machine code, and the. exe file on our computer is the result of the compilation. Again, for example, Python and JavaScript can only explain execution, the user gets the original code, the interpreter will be like a translator, a line of code to execute.
Why are WebAssembly smart contracts implemented in two ways? Because WebAssembly is similar to Java, it generates intermediate languages: bytecode, bytecode can be compiled into machine code after execution, and can be executed directly using the interpreter. The intermediate language gives WebAssembly a flexible way to execute. That's why EOS's smart contracts don't directly upload C + + files, they need to upload the compiled. wasm file, which is the middle language (bytecode) of WebAssembly.
The advantage of compile execution is that the execution is fast, but the disadvantage is that every time the intelligent contract is updated, the witness's server will recompile to generate the binary machine code, and it is not cost-effective for the intelligent contract with a few execution times. Interpreting execution is the opposite, no need to compile in advance, but execution speed is much slower than compile execution, Daniel says the speed is only 20%, that is, 5 times times slower than the original, but Daniel also shows that WebAssembly in the entire smart contract implementation of only a small part, The impact on real system performance is around 5%.
So toss a half-day, the effect is not original good? Daniel says the introduction of WebAssembly's official interpreter provides an authoritative reference to the results of the smart contract, and when the results of the compilation execution of the individual witnesses are inconsistent, the interpreter can be used to obtain a reference result. The interpreter will also make a post-build for the compiler, in case the WASM compiler fails to maintain the stability of the system.
At present, whether it is the EOS system, or WebAssembly technology is still in the rapid development stage, has not targeted to do more detailed optimization, I think WebAssembly can refer to the Java JIT (Just in time) technology, the high-frequency execution of the code to compile optimization , direct interpretation of the low-frequency code execution. But given that WebAssembly is not the main bottleneck for system performance, it now seems that demand is not urgent.
Reference documents:
1. Eosio Development Update
https://medium.com/@bytemaster/eosio-development-update-272198df22c1
2. Webassembly/binaryen
Https://github.com/WebAssembly/binaryen
3. Some things in the compilation (explain the main compiler techniques, including webassembly)
http://blog.csdn.net/qq_33280027/article/details/69944498
4. A few pictures let you understand webassembly
http://www.sohu.com/a/141587149_464084
Round circle block chain brings together a large number of blockchain teachers, to take the tutor on duty system, for students to solve technical problems in real-time. Please pay attention to the circle-radius blockchain Knowledge planet and mentor. (For training inquiries, please contact the Captain 13826054890 mobile phone number)
author Little flute , focusing on EOS technology research and blockchain smart contract development. Is the circle radius of the block chain tutor, more small flute teacher's articles and videos please pay attention to round circle ring public number.
EOS New WebAssembly Interpreter, what's the ghost?