4
头图

introduce

webAssembly is a set of binary machine language that runs on the browser. It has the characteristics of being small and fast.
You can C and C++ ( emscirpten ), Typescript ( AssemblyScript ), Rust ( WASM-Pack ) to write webAssembly .

webAssembly can run directly in the browser environment, or in the node environment.

timeline

Features

  • Running in a sandbox ensures environment isolation, so it can be used for virtual machine implementation.
  • Efficient, portable, and works on multiple platforms.

scenes to be used

browser environment

  • toolkits for some languages
  • game
  • Peer-to-peer applications such as blockchain
  • Music APP
  • image processing
  • Remote Desktop
  • encryption
  • local web server

non-browser environment

  • server application
  • Server-side sandbox environment
  • hybird native app

see more

WebAssembly key concepts

In javascript of API .

  • Module : The compiled binary, ending with the .wasm suffix.
  • Memory : ArrayBuffer , variable size. WebAssembly Requires manual memory management. WebAssembly is to divide the memory according to the unit of "page", a "page" is 32B (often seen i32 is this size).
  • Table : A typed array of variable size. Javascript wraps an object with an array-like structure, storing multiple function references.
  • Instance : is an executable instance of WebAssembly.Module . The example contains all  WebAssembly export functions.

Read webAssembly .
By converting the .wasm file to .wat . View grammar

refer to

Other articles


donggg
203 声望584 粉丝

> github