Pre-release WebAssembly 2.0 standard available

The W3C has published a draft of a new specification that standardizes the WebAssembly 2.0 staging code and associated API to enable the creation of high-performance applications that are portable across browsers and hardware platforms. WebAssembly provides a browser-independent, generic, low-level middleware for executing applications compiled from various programming languages. Through the use of JIT for WebAssembly, you can achieve a level of performance close to native code.

WebAssembly technology can be used to perform high-performance tasks in the browser, such as video encoding, audio processing, graphics and 3D manipulation, game development, cryptographic operations, and mathematical calculations, by executing code written in compiled languages ​​such as C/C++.

Among the main tasks of WebAssembly is the provision of portability, predictability of behavior and identity of code execution on different platforms. Recently, WebAssembly has also been promoted as a universal platform for secure code execution in any infrastructures, operating systems and devices, not limited to browsers.

The W3C has published three draft WebAssembly 2.0 specifications:

  • WebAssembly Core - describes a low-level virtual machine for executing WebAssembly intermediate code. WebAssembly-related resources come in a ".wasm" format, similar to Java's ".class" files, containing static data and code segments for working with that data.
  • WebAssembly JavaScript Interface - Provides an API for integrating with JavaScript. Allows you to get values ​​and pass parameters to WebAssembly functions. The execution of WebAssembly follows the JavaScript security model and all interaction with the main system is performed similarly to the execution of JavaScript code.
  • WebAssembly Web API - defines a API based on the Promise mechanism for requesting and executing ".wasm" resources. The WebAssembly resource format is optimized to start execution without waiting for the file to fully download, which improves the responsiveness of web applications.

The main changes in WebAssembly 2.0 compared to the first version of the standard:

  • Support for the v128 vector type and related vector instructions that allow you to perform operations on multiple numerical values ​​in parallel (SIMD, single instruction multiple data).
  • Ability to import and export mutable global variables, allowing global binding for values ​​such as stack pointers in C++.
  • New instructions for converting float to int, which instead of throwing an exception on result overflow, return the minimum or maximum possible value (required for SIMD).
  • Instructions for expanding the sign of integers (increasing the bit depth of a number while maintaining the sign and value).
  • Support for returning multiple values ​​by blocks and functions (in addition to passing multiple parameters to functions).
  • Implementing the BigInt64Array and BigUint64Array JavaScript functions to convert between the BigInt JavaScript type and the WebAssembly representation of 64-bit integers.
  • Support for reference types (funcref and externref) and their associated instructions (select, ref.null, ref.func and ref.is_null).
  • memory.copy, memory.fill, memory.init, and data.drop instructions for copying data between memory regions and clearing memory regions.
  • Instructions for direct access and modification of tables (table.set, table.get, table.size, table.grow). Ability to create, import and export multiple tables in one module. Functions for copying/filling tables in batch mode (table.copy, table.init and elem.drop).

Source: opennet.ru

Add a comment