How is WebAssembly cross-platform when Assembly is not

How is WebAssembly cross-platform when Assembly is not

  • WebAssembly is like , except that
    • it runs cross-platform
    • it runs isolated
    • it runs on
  • But how is WASM fast and cross-platform simultaneously?
    • Does it pack multiple precompiled binary executables for multiple CPU vendors, like Apple's Universal Binary?
    • But then, whenever a new type of CPU gets announced, they wouldn't be able to run existing WASMs
  • WebAssembly's runtime environments (RE) are low-level virtual stack machines (akin to or Flash VM)
  • Seems like WASM is closer to intermediate Byte Code instead of the genuinely low-level .
    • But then, why is it faster?
    • JS Interpreter can skip the parsing
    • It can ship in a much more compact file format
  • WASM is just like Byte-code. Byte-code is cross-platform when machine code for a real CPU is not. It's input for a JIT compiler that targets whatever real CPU. Peter Cordes
  • WASM defines its own _CPU standards and . WebAssembly Core Specification.
  • To run WASM, the must still the WASM code into ASM code when executing; in that way, it is much slower than WASM.
  • However, WASM is designed similarly to ASM. Therefore, WASM to ASM targeting x86, , and RISC-V, is comparably easy, and existing compilers emitting ASM can also emit WASM with a reasonable modification.
  • What is the relationship between WebAssembly and ?
  • It is a specific purpose .
  • It's designed with a specific abstract machine that would be expensive to implement in hardware.

References

  1. WebAssembly
  2. How is WebAssembly cross-platform when Assembly is not? - Stack Overflow
Backlinks1