From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Web Assembly Logo.svg
ParadigmImperative, structured, expression-oriented
Designed byW3C
First appearedMarch 2017; 2 years ago (2017-03)
Typing disciplineStatic
LicenseApache License 2.0
Filename extensions
  • .wat
  • .wasm
Influenced by

WebAssembly (often shortened to Wasm) is a set of web standards that define a portable modular binary format, and a corresponding language, similar to the assembly language for executable program and environment-specific program interfaces into which it may be embedded and interacted with.[1][2] The main goal of WebAssembly is to enable high performance applications on web pages, but it is designed to be executed and integrated in other environments as well.[3]

Wasm does not replace JavaScript; in order to use WASM in browsers, users may use Emscripten SDK to compile C++ (or any other LLVM-supported language such as D or Rust) source code into a binary file which runs in the same sandbox as regular JavaScript code, though only has access to an expandable memory and a small number of scalar values.[note 1] There is no direct Document Object Model (DOM) access; however, it is possible to create proxy functions for this, for example through stdweb,[8] web_sys,[9] and js_sys.[10] Emscripten provides bindings for several commonly used environment interfaces, such as like WebGL.

The World Wide Web Consortium (W3C) maintains the standard with contributions from Mozilla, Microsoft, Google, and Apple.[11]


WebAssembly was first announced in 2015,[12] and the first demonstration was executing Unity's Angry Bots in Firefox,[13] Google Chrome,[14] and Microsoft Edge.[15] The precursor technologies were asm.js from Mozilla and Google Native Client,[16][17] and the initial implementation was based on the feature set of asm.js.[18]

In March 2017, the design of the minimum viable product was declared to be finished and the preview phase ended.[19] In late September 2017, Safari 11 was released with support. In February 2018, the WebAssembly Working Group published three public working drafts for the Core Specification, JavaScript Interface, and Web API.[20][21][22][23]


In November 2017, Mozilla declared support "in all major browsers",[24] after WebAssembly was enabled by default in Edge 16.[25] The support includes mobile web browsers for iOS and Android. As of June 2018, 85.57% of installed browsers (and 87.21% of desktop browsers) support WebAssembly.[26] But for older browsers, Wasm can be compiled into asm.js by a JavaScript polyfill.[27]

Because WebAssembly executables are precompiled, it is possible to use a variety of programming languages to make them.[28] This is achieved either through direct compilation to Wasm, or through implementation of the corresponding virtual machines in Wasm. There have been around 40 programming languages reported to support Wasm as a compilation target.[29]

Emscripten can compile C and C++ to Wasm[19] using LLVM in the backend.

Its initial aim is to support compilation from C and C++,[30] though support for other source languages such as Rust and .NET languages is also emerging.[31][32][29] After the minimum viable product (MVP) release, there are plans to support multithreading and garbage collection[33] which would make WebAssembly a compilation target for garbage-collected programming languages like Java, Julia,[34][35] C# (supported via Blazor), and Go.

Use by malware[edit]

The method of delivery and execution of WebAssembly code allows malware writers, scammers and phishing attackers greater ease in hiding the evidence of their attack. In addition, WebAssembly is only present on the user's machine in its compiled form, which is inherently hard to analyze in order to identify malicious code.[36]

The speed and concealability of WebAssembly have led to its use in cryptomining attacks.[36][37][38] Coinhive, a service facilitating cryptocurrency mining in website visitors' browsers, which is done by malicious actors without the visitor's consent or knowledge, claimed their "miner uses WebAssembly and runs with about 65% of the performance of a native Miner."[38]

In June 2018, a security researcher presented the possibility of using WebAssembly to circumvent browser mitigations for Spectre and Meltdown security vulnerabilities once support for threads with shared memory is added. Due to this concern, WebAssembly developers put the feature on hold.[38][39][40] Thread support was eventually added in October 2018.[41]


The general standards provide core specifications for JavaScript and Web embedding.[1]

While WebAssembly was initially designed to enable near-native code execution speed in the web browser, it has been considered valuable outside of such, in more generalized contexts.[42][43]

WebAssembly System Interface (WASI) is an ABI designed by Mozilla intended to define a simpler ABI for WebAssembly that can be used in any platform.[44] There are also a few other proposed ABI APIs.[45][46]


Stack machine[edit]

Wasm code is intended to be run on a portable abstract structured virtual stack machine (VM).[47] The VM is designed to be faster to parse than JavaScript, as well as faster to execute and to enable very compact code representation.[30]

Instruction set[edit]

The core standard defines a unique Instruction Set Architecture consisting of specific binary encoding and which is intended to be executed by VM. However it doesn't specify how exactly they must be invoked by it.[48]


In March 2017, the WebAssembly Community Group reached consensus on the initial (MVP) binary format, JavaScript API, and reference interpreter.[49] It defines a WebAssembly binary format, which is not designed to be used by humans, as well as a human-readable linear assembly bytecode format that resembles traditional assembly languages.

The table below represents three different views of the same source code input from the left, as it is converted to a Wasm intermediate representation, then to Wasm binary instructions:[50]

C input source Linear assembly bytecode
(intermediate representation)
Wasm binary encoding
(hexadecimal bytes)
int factorial(int n) {
  if (n == 0)
    return 1;
    return n * factorial(n-1);
get_local 0
if (result i64)
    i64.const 1
    get_local 0
    get_local 0
    i64.const 1
    call 0
20 00
04 7E
42 01
20 00
20 00
42 01
10 00

The WebAssembly text format can also be written in a folded format using s-expressions. This format is purely syntactic sugar and has no behavioral differences with the linear format.[51] An example is shown below:

  (import "math" "exp" (func $exp (param f64) (result f64)))
  (func (export "doubleExp") (param $0 f64) (result f64)
      (call $exp
        (get_local $0)
      (f64.const 2)


  • Haas, Andreas; Rossberg, Andreas; Schuff, Derek L.; Titzer, Ben L.; Gohman, Dan; Wagner, Luke; Zakai, Alon; Bastien, JF; Holman, Michael (June 2017). "Bringing the web up to speed with WebAssembly". Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation. Association for Computing Machinery: 185–200. doi:10.1145/3062341.3062363.
  • Watt, Conrad (2018). "Mechanising and Verifying the WebAssembly Specification" (PDF). ACM SIGPLAN International Conference on Certified Programs and Proofs. ACM. 7. doi:10.1145/3167082.


  1. ^ According to official documentation the Emscripten SDK may be used to create .wasm files which then may be executed in web browser.[4][5][6] Even though Emscripten can consume various languages when using Clang some problems may arise.[7]


  1. ^ a b "Conventions — WebAssembly 1.0". webassembly.github.io. Retrieved 17 May 2019.
  2. ^ "WebAssembly Specifications". webassembly.github.io. Retrieved 17 May 2019. To support the embedding of WebAssembly into different environments, its specification is split into layers that are specified in separate documents.
  3. ^ "WebAssembly Specification Release 1.0 (Draft, last updated Apr 16, 2019): Introduction". webassembly.org. Retrieved 6 May 2019. Its main goal is to enable high performance applications on the Web, but it does not make any Web-specific assumptions or provide Web-specific features, so it can be employed in other environments as well.
  4. ^ "Developer's Guide - WebAssembly". webassembly.org. Retrieved 10 June 2019.
  5. ^ "Compiling a New C/C++ Module to WebAssembly". MDN Web Docs. Retrieved 10 June 2019.
  6. ^ "Building to WebAssembly — Emscripten 1.38.33 documentation". emscripten.org. Retrieved 10 June 2019.
  7. ^ "Emscripting a C library to Wasm | Web". Google Developers. Retrieved 10 June 2019.
  8. ^ "stdweb - Rust". docs.rs. Retrieved 5 June 2019. The goal of this crate is to provide Rust bindings to the Web APIs and to allow a high degree of interoperability between Rust and JavaScript.
  9. ^ "web_sys - Rust". docs.rs. Retrieved 5 June 2019. Raw API bindings for Web APIs. This is a procedurally generated crate from browser WebIDL which provides a binding to all APIs that browser provide on the web.
  10. ^ "js_sys - Rust". docs.rs. Retrieved 5 June 2019. Bindings to JavaScript's standard, built-in objects, including their methods and properties.
  11. ^ Bright, Peter (18 June 2015). "The Web is getting its bytecode: WebAssembly". Ars Technica. Condé Nast.
  12. ^ "Launch bug". GitHub / WebAssembly / design. 11 June 2015.
  13. ^ Wagner, Luke (14 March 2016). "A WebAssembly Milestone: Experimental Support in Multiple Browsers". Mozilla Hacks.
  14. ^ Thompson, Seth (15 March 2016). "Experimental support for WebAssembly in V8". V8 Blog.
  15. ^ Zhu, Limin (15 March 2016). "Previewing WebAssembly experiments in Microsoft Edge". Microsoft Edge dev blog.
  16. ^ Lardinois, Frederic (17 June 2015). "Google, Microsoft, Mozilla And Others Team Up To Launch WebAssembly, A New Binary Format For The Web". TechCrunch. Retrieved 24 December 2017.
  17. ^ Avram, Abel (31 May 2017). "Google Is to Remove Support for PNaCl". InfoQ. Retrieved 22 December 2017.
  18. ^ "WebAssembly: a binary format for the web". ②ality – JavaScript and more. 18 June 2015.
  19. ^ a b Krill, Paul (6 March 2017). "WebAssembly is now ready for browsers to use". InfoWorld. Retrieved 23 December 2017.
  20. ^ "WebAssembly First Public Working Drafts". W3C. 15 February 2018. Retrieved 20 April 2018.
  21. ^ "WebAssembly Core Specification". W3C. 15 February 2018. Retrieved 20 April 2018.
  22. ^ "WebAssembly JavaScript Interface". W3C. 15 February 2018. Retrieved 20 April 2018.
  23. ^ "WebAssembly Web API". W3C. 15 February 2018. Retrieved 20 April 2018.
  24. ^ "WebAssembly support now shipping in all major browsers". The Mozilla Blog. Retrieved 21 November 2017.
  25. ^ "Introducing new JavaScript optimizations, WebAssembly, SharedArrayBuffer, and Atomics in EdgeHTML 16". Microsoft Edge Dev Blog. Retrieved 21 November 2017.
  26. ^ "WebAssembly". Can I use. Retrieved 14 June 2019.
  27. ^ Bright, Peter (18 June 2015). "The Web is getting its bytecode: WebAssembly". Ars Technica. Retrieved 23 December 2017.
  28. ^ Ball, Kevin (26 June 2018). "How WebAssembly is Accelerating the Future of Web Development". Archived from the original (HTML) on 12 February 2019. Retrieved 22 October 2018.
  29. ^ a b "Awesome WebAssembly Languages". 26 June 2018. Archived from the original (HTML) on 12 February 2019. Retrieved 12 February 2019.
  30. ^ a b "WebAssembly High-Level Goals". GitHub / WebAssembly / design. 11 December 2015.
  31. ^ Krill, Paul (29 November 2017). "Direct WebAssembly compilation comes to Rust language". InfoWorld. Retrieved 24 December 2017.
  32. ^ "Frequently asked questions (FAQ) about Blazor". blazor.net. Retrieved 18 June 2018.
  33. ^ Krill, Paul (26 October 2017). "What's next for WebAssembly: GC, threads, debugging". TechWorld. Retrieved 24 December 2017.
  34. ^ "Julia in the Browser". nextjournal.com. Retrieved 9 April 2019.
  35. ^ "WebAssembly platform by tshort · Pull Request #2 · JuliaPackaging/Yggdrasil". GitHub. Retrieved 9 April 2019.
  36. ^ a b Lonkar, Aishwarya; Chandrayan, Siddhesh (October 2018). "The dark side of WebAssembly". Virus Bulletin. Retrieved 8 June 2019.
  37. ^ Segura, Jérôme (29 November 2017). "Persistent drive-by cryptomining coming to a browser near you". Malwarebytes. Retrieved 8 June 2019.
  38. ^ a b c Neumann, Robert; Toro, Abel (19 April 2018). "In-browser mining: Coinhive and WebAssembly". Forcepoint. Retrieved 8 June 2019.
  39. ^ Cimpanu, Catalin (24 June 2018). "Changes in WebAssembly Could Render Meltdown and Spectre Browser Patches Useless". Bleeping Computer. Retrieved 8 June 2019.
  40. ^ Sanders, James (25 June 2018). "How opaque WebAssembly code could increase the risk of Spectre attacks online". Tech Republic. Retrieved 9 June 2019.
  41. ^ R, Bhagyashree (30 October 2018). "Google Chrome 70 now supports WebAssembly threads to build multi-threaded web applications". Packt Pub. Retrieved 9 June 2019.
  42. ^ "Non-Web Embeddings". WebAssembly. Retrieved 15 May 2019.
  43. ^ "Non-Web Embeddings". GitHub / WebAssembly. Retrieved 15 May 2019.
  44. ^ "WebAssembly System Interface Repo". GitHub / WebAssembly.
  45. ^ "reference-sysroot Repo". GitHub / WebAssembly.
  46. ^ "wasm-c-api Repo". GitHub / WebAssembly.
  47. ^ "Design Rationale". GitHub / WebAssembly / design. 1 October 2016.
  48. ^ "Introduction — WebAssembly 1.0". webassembly.github.io. Retrieved 17 May 2019.
  49. ^ "Roadmap". WebAssembly. March 2017.
  50. ^ jfbastien; rossberg-chromium; kripken; titzer; s3ththompson; sunfishcode; lukewagner; flagxor; enricobacis; c3d; binji; andrewosh (9 March 2017). "Text Format". WebAssembly/design. GitHub.
  51. ^ "Folded instructions". GitHub. / WebAssembly / spec

Cite error: A list-defined reference named "github.com/WebAssembly" is not used in the content (see the help page).

Definition of Free Cultural Works logo notext.svg This article incorporates text from a free content work. Licensed under Apache License 2.0 License statement: Text Format, jfbastien; rossberg-chromium; kripken; titzer; s3ththompson; sunfishcode; lukewagner; flagxor; enricobacis; c3d; binji; andrewosh, GitHub. WebAssembly/design. To learn how to add open license text to Wikipedia articles, please see this how-to page. For information on reusing text from Wikipedia, please see the terms of use.


  • Widgets demo: [1] with NWSTK
  • 3D mountain geometry synthesis demo: [2] with NWSTK
  • Demo for loading and drawing a jpg file: [3] with NWSTK

External links[edit]