WebAssembly: Difference between revisions
→History: Added additional information about the usage of asm.js in this context. |
→Implementations: Fixed grammar Tags: canned edit summary Mobile edit Mobile app edit Android app edit App section source |
||
(344 intermediate revisions by more than 100 users not shown) | |||
Line 1: | Line 1: | ||
{{Short description|Assembly language and bytecode for web browsers}} |
|||
{{Use dmy dates|date=March 2016}} |
|||
{{Use dmy dates|date=February 2020}} |
|||
{{Short description|binary format for executables used by web pages}} |
|||
{{Infobox programming language |
{{Infobox programming language |
||
| title = WebAssembly |
| title = WebAssembly |
||
| logo = |
| logo = WebAssembly Logo.svg |
||
| logo caption = |
| logo caption = |
||
| screenshot = <!-- (filename) --> |
| screenshot = <!-- (filename) --> |
||
| screenshot caption = |
| screenshot caption = |
||
| paradigm = [[Structured programming|structured]]; [[stack machine]]<ref>{{Cite web|title=WebAssembly/design/Semantics.md|url=https://github.com/WebAssembly/design/blob/376bcc4b9cba79280d79be023d71e30d0b00ba47/Semantics.md|access-date=2021-02-23|website=GitHub|language=en|quote=WebAssembly code can be considered a ''structured stack machine''; a machine where most computations use a stack of values, but control flow is expressed in structured constructs such as blocks, ifs, and loops. In practice, implementations need not maintain an actual value stack, nor actual data structures for control; they need only behave as if they did so.}}</ref> <!-- [[Imperative programming|Imperative]], [[Expression-oriented programming language|expression-oriented]] (any paradigm for language running on top) --> |
|||
| paradigm = [[Imperative programming|Imperative]], [[Structured programming|structured]], [[Expression-oriented programming language|expression-oriented]] |
|||
| family = |
| family = |
||
| released = {{Start date and age|2017|3}} |
| released = {{Start date and age|df=yes|2017|3}} |
||
| designer = [[World Wide Web Consortium|W3C]] |
| designer = [[World Wide Web Consortium|W3C]] |
||
| developer = {{Unbulleted list|[[World Wide Web Consortium|W3C]]|[[Mozilla]]|[[Microsoft]]|[[Google]]|[[Apple Inc.|Apple]]}} |
| developer = {{Unbulleted list|[[World Wide Web Consortium|W3C]]|[[Mozilla]]|[[Microsoft]]|[[Google]]|[[Apple Inc.|Apple]]}} |
||
| latest release version = |
| latest release version = |
||
| latest release date = |
| latest release date = |
||
| typing = <!--Not applicable to assembly languages such as WebAssembly; this field is meant for high-level programming languages--> |
|||
| typing = [[Type system|Static]] |
|||
| operating system = [[Platform independent]] |
|||
| scope = |
|||
| scope = |
|||
| implementations = |
|||
| implementations = |
|||
| dialects = |
|||
| dialects = |
|||
| influenced by = {{Hlist|[[asm.js]]|[[Google Native Client|PNaCl]]}} |
|||
| influenced = |
|||
| programming language = |
|||
| license = [[Apache License 2.0]] |
| license = [[Apache License 2.0]] |
||
| programming language = |
|||
| file extensions = {{Unbulleted list|.wat|.wasm}} |
|||
| file extensions = {{Unbulleted list|{{mono|.wat}} (text format)|{{mono|.wasm}} (binary format)}} |
|||
| file format = <!-- or: | file formats = --> |
| file format = <!-- or: | file formats = --> |
||
| influenced by = {{Hlist|[[asm.js]]|[[Google Native Client|PNaCl]]|[[Lisp (programming language)|Lisp]]}} |
|||
| influenced = |
|||
}} |
}} |
||
'''WebAssembly''' ('''Wasm''') defines a [[software portability|portable]] [[binary code|binary-code]] format and a corresponding text format for [[executable|executable programs]]<ref>{{cite web |author1=Mozilla |title=Understanding WebAssembly text format |url=https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format |access-date=9 December 2019 |website=MDN Web Docs |language=en-US}} |
|||
</ref> as well as [[software]] interfaces for facilitating communication between such programs and their host environment.<ref>{{Cite web| |
|||
url=https://webassembly.github.io/spec/core/intro/introduction.html| |
|||
title=Introduction — WebAssembly 1.0|website=webassembly.github.io| |
|||
access-date=18 June 2019| |
|||
quote=WebAssembly is an open standard...}} |
|||
</ref><ref>{{Cite web| |
|||
url=https://webassembly.github.io/spec/core/intro/introduction.html| |
|||
title=Introduction — WebAssembly 1.0|website=webassembly.github.io|access-date=18 June 2019| |
|||
quote=WebAssembly is a ... code format}}</ref><ref name=":0">{{Cite web| |
|||
url=https://webassembly.github.io/spec/core/syntax/conventions.html| |
|||
title=Conventions — WebAssembly 1.0| |
|||
website=webassembly.github.io| |
|||
access-date=17 May 2019| |
|||
quote=WebAssembly is a programming language that has multiple concrete representations (its binary format and the text format). Both map to a common structure.}}</ref><ref>{{Cite web| |
|||
url=https://webassembly.github.io/spec/core/intro/introduction.html| |
|||
title=Introduction — WebAssembly 1.0|website=webassembly.github.io| |
|||
access-date=18 June 2019| |
|||
quote=... this specification is complemented by additional documents defining interfaces to specific embedding environments such as the Web. These will each define a WebAssembly application programming interface (API) suitable for a given environment.}} |
|||
</ref> |
|||
The main goal of WebAssembly is to facilitate high-performance applications on [[web page]]s, but it is also designed to be usable in non-web environments.<ref>{{Cite web| |
|||
'''WebAssembly''' (often shortened to '''Wasm''') is an [[open standard]] that defines a [[software portability|portable]] [[binary code|binary]] code format for [[executable|executable programs]], and a corresponding textual [[assembly language]], as well as interfaces for facilitating interactions between such programs and their host environment.<ref>{{Cite web|url=https://webassembly.github.io/spec/core/intro/introduction.html|title=Introduction — WebAssembly 1.0|website=webassembly.github.io|access-date=2019-06-18|quote=WebAssembly is an open standard...}}</ref><ref>{{Cite web|url=https://webassembly.github.io/spec/core/intro/introduction.html|title=Introduction — WebAssembly 1.0|website=webassembly.github.io|access-date=2019-06-18|quote=WebAssembly is a ... code format}}</ref><ref name=":0">{{Cite web|url=https://webassembly.github.io/spec/core/syntax/conventions.html|title=Conventions — WebAssembly 1.0|website=webassembly.github.io|access-date=2019-05-17|quote=WebAssembly is a programming language that has multiple concrete representations (its binary format and the text format). Both map to a common structure.}}</ref><ref>{{Cite web|url=https://webassembly.github.io/spec/core/intro/introduction.html|title=Introduction — WebAssembly 1.0|website=webassembly.github.io|access-date=2019-06-18|quote=... this specification is complemented by additional documents defining interfaces to specific embedding environments such as the Web. These will each define a WebAssembly application programming interface (API) suitable for a given environment.}}</ref> The main goal of WebAssembly is to enable high performance applications on [[web page]]s, but the format is designed to be executed and integrated in other environments as well.<ref>{{Cite web|url=https://webassembly.github.io/spec/core/intro/introduction.html|title=WebAssembly Specification Release 1.0 (Draft, last updated Apr 16, 2019): Introduction|website=webassembly.org|access-date=2019-05-06|quote=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.}}</ref><ref>{{Cite journal|last=Haas|first=Andreas|last2=Rossberg|first2=Andreas|last3=Schuff|first3=Derek L.|last4=Titzer|first4=Ben L.|last5=Holman|first5=Michael|last6=Gohman|first6=Dan|last7=Wagner|first7=Luke|last8=Zakai|first8=Alon|last9=Bastien|first9=JF|date=2017-06-14|title=Bringing the Web Up to Speed with WebAssembly|journal=SIGPLAN Notices|volume=52|issue=6|pages=185–200|doi=10.1145/3140587.3062363|issn=0362-1340|quote=While the Web is the primary motivation for WebAssembly, nothing in its design depends on the Web or a JavaScript environment. It is an open standard specifically designed for embedding in multiple contexts, and we expect that stand-alone implementations will become available in the future.}}</ref> |
|||
title=Introduction — WebAssembly 1.1| |
|||
url=https://webassembly.github.io/spec/core/intro/introduction.html| |
|||
access-date=2021-02-19| |
|||
quote=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.| |
|||
website=webassembly.github.io}} |
|||
</ref> It is an [[open standard]]<ref>{{Cite journal| |
|||
last1=Haas|first1=Andreas| |
|||
last2=Rossberg|first2=Andreas| |
|||
last3=Schuff|first3=Derek L.| |
|||
last4=Titzer|first4=Ben L.| |
|||
last5=Holman|first5=Michael| |
|||
last6=Gohman|first6=Dan| |
|||
last7=Wagner|first7=Luke| |
|||
last8=Zakai|first8=Alon| |
|||
last9=Bastien|first9=JF| |
|||
date=14 June 2017| |
|||
title=Bringing the Web Up to Speed with WebAssembly| |
|||
journal=SIGPLAN Notices|volume=52|issue=6|pages=185–200|doi=10.1145/3140587.3062363|issn=0362-1340| |
|||
quote=While the Web is the primary motivation for WebAssembly, nothing in its design depends on the Web or a JavaScript environment. It is an open standard specifically designed for embedding in multiple contexts, and we expect that stand-alone implementations will become available in the future.|doi-access=free}} |
|||
</ref><ref name=":1"/> intended to support any language on any operating system,<ref name="Wasmer" /> and in practice many of the most popular languages already have at least some level of support. |
|||
Announced in {{Start date|2015}} and first released in {{Start date|2017|3}}, WebAssembly became a [[World Wide Web Consortium]] recommendation on 5 December 2019<ref>{{cite web | |
|||
Wasm does not replace [[JavaScript]]; in order to use Wasm in browsers, users may use [[Emscripten|Emscripten SDK]] to compile C++ (or any other [[LLVM]]-supported language such as [[D (programming language)|D]] or [[Rust (programming language)|Rust]]) source code into a binary file which runs in the same [[sandbox (computer security)|sandbox]] as regular JavaScript code;{{Refn|group=note|According to official documentation the Emscripten SDK may be used to create <code>.wasm</code> files which then may be executed in web browser.<ref>{{Cite web|url=https://webassembly.org/getting-started/developers-guide/|title=Developer's Guide - WebAssembly|website=webassembly.org|access-date=2019-06-10}}</ref><ref>{{Cite web|url=https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm|title=Compiling a New C/C++ Module to WebAssembly|website=MDN Web Docs|language=en|access-date=2019-06-10}}</ref><ref>{{Cite web|url=https://emscripten.org/docs/compiling/WebAssembly.html|title=Building to WebAssembly — Emscripten 1.38.33 documentation|website=emscripten.org|access-date=2019-06-10}}</ref> Even though Emscripten can consume various languages when using [[Clang]] some problems may arise.<ref>{{Cite web|url=https://developers.google.com/web/updates/2018/03/emscripting-a-c-library|title=Emscripting a C library to Wasm {{!}} Web|website=Google Developers|language=en|access-date=2019-06-10}}</ref>}} Emscripten provides bindings for several commonly used environment interfaces like [[WebGL]]; it has access only to an expandable memory and a small number of scalar values.{{Clarify|reason=Specify which environment.|date=June 2019}}{{Citation needed|date=June 2019}} There is no direct [[Document Object Model]] (DOM) access; however, it is possible to create proxy functions for this, for example through stdweb,<ref>{{Cite web|url=https://docs.rs/stdweb/*/stdweb/|title=stdweb - Rust|website=docs.rs|access-date=2019-06-05|quote=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.}}</ref> web_sys,<ref>{{Cite web|url=https://docs.rs/web-sys/*/web_sys/|title=web_sys - Rust|website=docs.rs|access-date=2019-06-05|quote=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.}}</ref> and js_sys<ref>{{Cite web|url=https://docs.rs/js-sys/*/js_sys/|title=js_sys - Rust|website=docs.rs|access-date=2019-06-05|quote=Bindings to JavaScript's standard, built-in objects, including their methods and properties.}}</ref> when using [[Rust (programming language)|Rust language]]. |
|||
author1=World Wide Web Consortium | |
|||
title=WebAssembly Core Specification | |
|||
url=https://www.w3.org/TR/wasm-core-1/ | |
|||
website=World Wide Web Consortium (W3) |access-date=9 December 2019}} |
|||
</ref><ref>{{cite web | |
|||
last1=Couriol |first1=Bruno | |
|||
title=WebAssembly 1.0 Becomes a W3C Recommendation and the Fourth Language to Run Natively in Browsers | |
|||
url=https://www.infoq.com/news/2019/12/webassembly-w3c-recommendation/ | |
|||
website=infoq.com |access-date=9 December 2019}} |
|||
</ref><ref>{{Cite web|title=WebAssembly Specification — WebAssembly 1.1| |
|||
url=https://webassembly.github.io/spec/core/| |
|||
access-date=2021-03-22|website=webassembly.github.io}} |
|||
</ref> and it received the ''Programming Languages Software Award'' from [[Association for Computing Machinery|ACM]] [[SIGPLAN]] in 2021.<ref>{{Cite web| |
|||
url=http://www.sigplan.org/Awards/Software/| |
|||
title=Programming Languages Software Award| |
|||
website=www.sigplan.org}} |
|||
</ref> The [[World Wide Web Consortium]] (W3C) maintains the standard with contributions from [[Mozilla]], [[Microsoft]], [[Google]], [[Apple Inc.|Apple]], [[Fastly]], [[Intel]], and [[Red Hat]].<ref name="ars"/><ref name="bytecode"/> |
|||
== History == |
|||
The [[World Wide Web Consortium]] (W3C) maintains the standard with contributions from [[Mozilla]], [[Microsoft]], [[Google]], and [[Apple Inc.|Apple]].<ref name="ars"/> |
|||
The name WebAssembly is intended to seem synonymous with that of the [[assembly language]]. The name suggests bringing assembly-like programming to the [[World Wide Web|Web]], where it will be executed [[client-side]] {{mdash}} by the website-user's computer via the user's [[web browser]]. To accomplish this, WebAssembly must be much more hardware-independent than a true assembly language. |
|||
WebAssembly was first announced in 2015,<ref name="Launch bug"/> and the first demonstration was executing [[Unity (game engine)|Unity]]'s ''Angry Bots'' in [[Firefox]],<ref name="Unity in Firefox"/> [[Google Chrome]],<ref name="V8 blog"/> and [[Microsoft Edge]].<ref name="Edge"/> The precursor technologies were [[asm.js]] from [[Mozilla]] and [[Google Native Client]],<ref name="techcrunch2015"/><ref name="PNaCl"/> and the initial implementation was based on the feature set of asm.js.<ref name="initial implementation"/>{{Refn|group=note|The asm.js file already provides near-native code execution speeds: "Even discarding the one score where asm.js did better, it executes at around 70% of the speed (i.e. slower) of native C++ code.<ref>{{Cite web|url=https://blog.mozilla.org/javascript/2013/08/01/staring-at-the-sun-dalvik-vs-spidermonkey/|title=Staring at the Sun: Dalvik vs. ASM.js vs. Native|website=blog.mozilla.org|date=August 2013 |access-date=7 December 2019}}</ref> and can be considered a viable alternative for browsers that do not support WebAssembly or have it disabled for security reasons.}} |
|||
A June 2019 study from the Technische Universität Braunschweig, analyzed the usage of WebAssembly in the Alexa top 1 million websites and found the most prevalent use was for malicious [[Cryptocurrency#Mining|crypto mining]].<ref>{{Cite web|url=https://www.infoq.com/news/2019/10/WebAssembly-wasm-malicious-usage/|title=Recent Study Estimates That 50% of Websites Using WebAssembly Apply It for Malicious Purposes|website=InfoQ|access-date=2019-11-03}}</ref><ref>https://www.tu-braunschweig.de/Medien-DB/ias/pubs/2019-dimva.pdf</ref><ref>https://www.dimva2019.org/wp-content/uploads/sites/31/2019/06/DIMVA19-slides-2-R.pdf</ref> |
|||
In March 2017, the design of the [[minimum viable product]] (MVP) was declared to be finished and the preview phase ended.<ref name="MVP"/> In late September 2017, [[Safari (web browser)|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.<ref name="W3C-WD2018" /><ref name="W3C-CSWD2018" /><ref name="W3C-JIWD2018" /><ref name="W3C-WAWD2018" /> |
|||
== History == |
|||
WebAssembly was first announced in 2015,<ref name="Launch bug"/> and the first demonstration was executing [[Unity (game engine)|Unity]]'s ''Angry Bots'' in [[Firefox]],<ref name="Unity in Firefox"/> [[Google Chrome]],<ref name="V8 blog"/> and [[Microsoft Edge]].<ref name="Edge"/> The precursor technologies were [[asm.js]] from [[Mozilla]] and [[Google Native Client]],<ref name="techcrunch2015"/><ref name="PNaCl"/> and the initial implementation was based on the feature set of asm.js.<ref name="initial implementation"/> The asm.js technology already provides near-native code execution speeds<ref>{{Cite web|url=https://blog.mozilla.org/javascript/2013/08/01/staring-at-the-sun-dalvik-vs-spidermonkey/|title=Staring at the Sun: Dalvik vs. ASM.js vs. Native|website=blog.mozilla.org|access-date=2019-12-07|quote=Even discarding the one score where asm.js did better, it executes at around 70% of the speed of native C++ code.}}</ref> and can be considered a viable alternative for browsers that don't support WebAssembly or have it disabled for security reasons. |
|||
In June 2019, Chrome 75 was released with WebAssembly threads enabled by default.<ref>{{Cite web|title=WebAssembly Worker Based Threads - Chrome Platform Status|url=https://chromestatus.com/feature/5724132452859904|access-date=2022-02-19|website=chromestatus.com}}</ref> |
|||
In March 2017, the design of the [[minimum viable product]] (MVP) was declared to be finished and the preview phase ended.<ref name="MVP"/> {{As of|2017|September|alt=In late September 2017}}, [[Safari (web browser)|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.<ref name="W3C-WD2018" /><ref name="W3C-CSWD2018" /><ref name="W3C-JIWD2018" /><ref name="W3C-WAWD2018" /> |
|||
{{as of|April 2022|since=y|post=,}} WebAssembly 2.0 has been in draft status,<ref>{{Cite web |title=WebAssembly Specification — WebAssembly 2.0 (Draft 2022-09-01) |url=https://webassembly.github.io/spec/core/ |access-date=2022-09-09 |website=webassembly.github.io}}</ref><ref>{{Cite web |title=WebAssembly 2.0 First Public Working Drafts {{!}} W3C News |date=19 April 2022 |url=https://www.w3.org/blog/news/archives/9509 |access-date=2022-09-09 |language=en-US}}</ref> which added many [[SIMD]]-related instructions and a new v128 datatype, with the ability for functions to return multiple values, and mass memory initialize/copy. |
|||
== Support == |
|||
In November 2017, Mozilla declared support "in all major browsers"<ref name="in browsers"/> (by now all major on mobile and desktop), after WebAssembly was enabled by default in Edge 16.<ref name="Edge16"/> The support includes mobile web browsers for iOS and Android. <!--While outdated, no longer supported, Android 4.4.4 KitKat and older versions don't have WebViews that support.--> {{As of|2019|12}}, 88.66% of installed browsers (89.93% of desktop browsers<!--"tracked desktop"--> and 89.5% of mobile browsers<!--"tracked mobile"-->) support WebAssembly.<ref name="caniuse.com"/> |
|||
But for older browsers, Wasm can be compiled into asm.js by a JavaScript [[polyfill (programming)|polyfill]].<ref name="ars2015"/> |
|||
== Implementations == |
|||
Because WebAssembly [[executable]]s are precompiled, it is possible to use a variety of programming languages to make them.<ref name=AcceleratingWeb/> This is achieved either through direct compilation to Wasm, or through implementation of the corresponding [[Virtual machine#Process virtual machines|virtual machines]] in Wasm. There have been around 40 programming languages reported to support Wasm as a compilation target.<ref name=Implementations/> |
|||
While WebAssembly was initially designed to permit near-native code execution speed in the web browser, it has been considered valuable outside of such, in more generalized contexts.<ref name="nonweb">{{cite web|title=Non-Web Embeddings|url=https://webassembly.org/docs/non-web/|access-date=15 May 2019|work=WebAssembly}}</ref><ref name="nonwebsrc">{{cite web|title=Non-Web Embeddings|url=https://github.com/WebAssembly/design/blob/master/NonWeb.md|access-date=15 May 2019|work=[[GitHub]] / WebAssembly}}</ref> Since WebAssembly's runtime environments (RE) are low-level [[stack machine|virtual stack machines]] (akin to [[Java virtual machine|JVM]] or [[Adobe Flash|Flash VM]]) that may be embedded into host applications, some implementations create standalone runtime environments like {{wdrl|Q119398768}} and {{wdrl|Q105554548}}.<ref name=":1">{{Cite web|title=Outside the web: standalone WebAssembly binaries using Emscripten · V8|url=https://v8.dev/blog/emscripten-standalone-wasm#running-in-wasm-runtimes|access-date=2020-07-28|website=v8.dev}}</ref><ref name="Wasmer">{{Cite web|title=Wasmer - The Universal WebAssembly Runtime|url=https://wasmer.io/|quote=Compile everything to WebAssembly. Run it on any OS or embed it into other languages.|access-date=2021-02-19|website=wasmer.io}}</ref> WebAssembly runtime environments are embedded in [[application server]]s to host "server-side" WebAssembly applications and in other applications to support [[plug-in (computing)|plug-in]]-based software extension architectures, e.g., "WebAssembly for Proxies" (proxy-wasm) which specifies a WebAssembly-based [[application binary interface|ABI]] for extending [[proxy server]]s.<ref>{{cite web |url=https://konghq.com/blog/engineering/proxy-wasm |last=Freese |first=Danny |date=2023-10-03 |df=mdy |title=Proxy-Wasm: It's WebAssembly for Proxies |department=Blog |website=[[Kong Inc.|Kong]] |access-date=2024-05-06}}</ref><ref>{{cite web |url=https://github.com/proxy-wasm/spec |title=proxy-wasm/spec: WebAssembly for Proxies (ABI specification) |website=[[GitHub]] |access-date=2024-05-06}}</ref> |
|||
=== Web browsers<span class="anchor" id="Support"></span> === |
|||
[[Emscripten]] compiles [[C (programming language)|C]] and [[C++]] to Wasm<ref name="MVP"/> using the [[LLVM]] backend.<ref>{{Cite tweet|user=kripken|number=1186407352880074752|title=Emscripten has switched to the upstream LLVM wasm backend by default! / Details:<nowiki>https://groups.google.com/forum/#!topic/emscripten-discuss/NpxVAOirSl4</nowiki> …|last=Zakai|first=Alon|date=2019-10-21|access-date=2019-10-22}}</ref> |
|||
In November 2017, Mozilla declared support "in all major browsers",<ref name="in browsers"/> after WebAssembly was enabled by default in Edge 16.<ref name="Edge16"/> This support also includes mobile web browsers for iOS and Android. <!-- While outdated, no longer supported, Android 4.4.4 KitKat and older versions don't have WebView support, Android 5 does. --> {{As of|2024|3|post=,}} 99% of tracked web browsers <!-- 98.77%, 97.35% including browsers not tracked --> support WebAssembly (version 1.0),<ref name="canIuse.com"/> more than for its predecessor [[asm.js]].<ref>{{Cite web |title=asm.js {{!}} Can I use... Support tables for HTML5, CSS3, etc |url=https://caniuse.com/asmjs |access-date=2024-09-29 |website=caniuse.com}}</ref> <!-- For older browsers, Wasm can be compiled into asm.js by a JavaScript [[polyfill (programming)|polyfill]].<ref name="ars2015"/> --> For some extensions, from the 2.0 draft standard, support may be lower, but still more than 90% of web browsers may already support, e.g. the reference types extension.<ref>{{Cite web |title=WebAssembly Reference Types {{!}} Can I use... Support tables for HTML5, CSS3, etc |url=https://caniuse.com/wasm-reference-types |access-date=2024-03-03 |website=caniuse.com}}</ref> |
|||
== Compilers == |
|||
As of version 8<ref>{{Cite web|url=https://releases.llvm.org/8.0.0/docs/ReleaseNotes.html#changes-to-the-webassembly-target|title=LLVM 8.0.0 Release Notes — LLVM 8 documentation|website=releases.llvm.org|access-date=2019-10-22}}</ref> Clang alone can compile C and C++ to Wasm. |
|||
WebAssembly implementations usually use either [[ahead-of-time compilation|ahead-of-time]] (AOT) or [[just-in-time compilation|just-in-time]] (JIT) compilation, but may also use an [[Interpreter (computing)|interpreter]]. While the first implementations have landed in [[web browser]]s, there are also non-browser implementations for general-purpose use, including Wasmer,<ref name="Wasmer" /> Wasmtime<ref>{{cite web |title=Wasmtime — a small and efficient runtime for WebAssembly & WASI |url=https://wasmtime.dev/ |access-date=2020-12-18 |website=wasmtime.dev}}</ref> or WAMR,<ref name="bytecode" /> wasm3, WAVM, and many others.<ref>{{cite web |title=Roadmap |url=https://webassembly.org/roadmap/ |access-date=2021-12-07 |website=}}</ref> |
|||
Because WebAssembly [[executable]]s are precompiled, it is possible to use a variety of programming languages to make them.<ref name=AcceleratingWeb/> This is achieved either through direct compilation to Wasm, or through an implementation of their corresponding [[Virtual machine#Process virtual machines|virtual machines]] in Wasm. Some 40 programming languages are reported to support Wasm as a compilation target.<ref name=Implementations/> |
|||
Its initial aim is to support [[compilation (computing)|compilation]] from [[C (programming language)|C]] and [[C++]],<ref name="github.com"/> though support for other source [[programming language|languages]] such as [[Rust (programming language)|Rust]] and [[.NET languages]] is also emerging.<ref name="Rust"/><ref>{{Cite web|url=https://blazor.net/docs/introduction/faq.html|title=Frequently asked questions (FAQ) about Blazor|website=blazor.net|access-date=2018-06-18}}</ref><ref name=Implementations/> After the MVP release, there are plans to support [[Thread (computing)#Multithreading|multithreading]] and [[garbage collection (computer science)|garbage collection]]<ref name="next"/><ref>{{Cite web|url=https://github.com/WebAssembly/proposals/issues/16|title=🛤 Garbage collection · Issue #16 · WebAssembly/proposals|website=GitHub|language=en|access-date=2019-07-25}}</ref> which would make WebAssembly a compilation target for garbage-collected programming languages like [[C Sharp (programming language)|C#]] (supported via [[Blazor]]) and [[F Sharp (programming language)|F#]] (supported via Bolero<ref>{{Cite web|url=https://fsbolero.io/|title=Bolero: F# in WebAssembly|website=fsbolero.io|access-date=2019-07-25}}</ref> with help of Blazor); a number of other languages have some support including [[Java (programming language)|Java]], [[Julia (programming language)|Julia]],<ref>{{Cite web|url=https://nextjournal.com/sdanisch/wasm-julia|title=Julia in the Browser |website=nextjournal.com|access-date=2019-04-09}}</ref><ref>{{Cite web|url=https://github.com/JuliaPackaging/Yggdrasil/pull/2|title=WebAssembly platform by tshort · Pull Request #2 · JuliaPackaging/Yggdrasil|website=GitHub|language=en|access-date=2019-04-09}}</ref><ref>{{Citation|last=Fischer|first=Keno|title=GitHub - Keno/julia-wasm: Running julia on wasm.|date=2019-07-22|url=https://github.com/Keno/julia-wasm|access-date=2019-07-25}}</ref> [[Ruby (programming language)|Ruby]],<ref>{{Cite web|url=https://ruby.dj/|title=MRuby in Your Browser|website=ruby.dj|access-date=2019-07-25}}</ref> as well as [[Go (programming language)|Go]]. |
|||
[[Emscripten]] compiles [[C (programming language)|C]] and [[C++]] to Wasm<ref name="MVP"/> using [[Clang]] as a frontend, replacing [[LLVM]] as backend and using {{wdrl|Q131308722}} as an optimizer.<ref>{{cite tweet |user=kripken |number=1186407352880074752 |title=Emscripten has switched to the upstream LLVM wasm backend by default! / Details:<nowiki>https://groups.google.com/forum/#!topic/emscripten-discuss/NpxVAOirSl4</nowiki> |last=Zakai |first=Alon |date=21 October 2019 |access-date=22 October 2019}}</ref> The [[Emscripten|Emscripten SDK]] can compile any [[LLVM]]-supported languages (such as [[C (programming language)|C]], [[C++]] or [[Rust (programming language)|Rust]], among others) source code into a binary file which runs in the same [[sandbox (computer security)|sandbox]] as JavaScript code.{{Refn|group=note|According to official documentation, the Emscripten SDK may be used to create <code>.wasm</code> files which then may be executed in a web browser.<ref>{{cite web |url=https://webassembly.org/getting-started/developers-guide/|title=Developer's Guide - WebAssembly |website=webassembly.org |access-date=10 June 2019}}</ref><ref>{{cite web |url=https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm |title=Compiling a New C/C++ Module to WebAssembly |website=MDN Web Docs |language=en |access-date=10 June 2019}}</ref><ref>{{cite web |url=https://emscripten.org/docs/compiling/WebAssembly.html |title=Building to WebAssembly — Emscripten 1.38.33 documentation |website=emscripten.org |access-date=10 June 2019}}</ref> Even though Emscripten can consume various languages when using [[Clang]], some problems may arise.<ref>{{cite web |url=https://developers.google.com/web/updates/2018/03/emscripting-a-c-library |title=Emscripting a C library to Wasm {{!}} Web |website=Google Developers |language=en |access-date=10 June 2019}}</ref>}} Emscripten provides bindings for several commonly used environment interfaces like [[WebGL]]. |
|||
As of version 8, a standalone [[Clang]] can compile [[C (programming language)|C]] and [[C++]] to Wasm.<ref>{{cite web |title=LLVM 8.0.0 Release Notes — LLVM 8 documentation |url=https://releases.llvm.org/8.0.0/docs/ReleaseNotes.html#changes-to-the-webassembly-target |access-date=22 October 2019 |website=releases.llvm.org}}</ref> Its initial aim was to support [[compilation (computing)|compilation]] from [[C (programming language)|C]] and [[C++]],<ref name="github.com"/> though support for other source [[programming language|languages]] such as [[Rust (programming language)|Rust]], [[.NET languages]]<ref name="Rust" /><ref>{{cite web |title=Frequently asked questions (FAQ) about Blazor |url=https://blazor.net/docs/introduction/faq.html |access-date=18 June 2018 |website=blazor.net}}</ref><ref name="Implementations" /> and [[AssemblyScript]]<ref>{{cite web |title=AssemblyScript/assemblyscript |date=2020-09-09 |url=https://github.com/AssemblyScript/assemblyscript |publisher=The AssemblyScript Project |access-date=2020-09-09}}</ref> ([[TypeScript]]-like) is also emerging. |
|||
After the MVP release, WebAssembly added support for [[Thread (computing)#Single-threaded vs multithreaded programs|multithreading]] and [[Garbage collection (computer science)|garbage collection]] ('''WasmGC''', and web browsers including Safari have added support for it),<ref>{{cite web |title=WebAssembly Garbage Collection (WasmGC) now enabled by default in Chrome {{!}} Blog |url=https://developer.chrome.com/blog/wasmgc |access-date=2023-12-11 |website=Chrome for Developers |language=en}}</ref> which allowed more efficient compilation for garbage-collecting programming languages like [[C Sharp (programming language)|C#]] (supported via [[Blazor]]), [[F Sharp (programming language)|F#]] (supported via Bolero<ref>{{cite web |url=https://fsbolero.io/ |title=Bolero: F# in WebAssembly |website=fsbolero.io |access-date=25 July 2019}}</ref> with help of Blazor) and [[Python (programming language)|Python]].<ref>{{cite web |title=A new way to bring garbage collected programming languages efficiently to WebAssembly · V8 |url=https://v8.dev/blog/wasm-gc-porting#demo-and-status |access-date=2023-12-11 |website=v8.dev}}</ref> |
|||
A number of other languages have some support, including [[Python (programming language)|Python]],<ref>{{cite web |title=Pyodide: Bringing the scientific Python stack to the browser – Mozilla Hacks - the Web developer blog |url=https://hacks.mozilla.org/2019/04/pyodide-bringing-the-scientific-python-stack-to-the-browser |access-date=2020-09-09 |website=Mozilla Hacks – the Web developer blog |language=en-US}}</ref> [[Julia (programming language)|Julia]],<ref>{{cite web |url=https://nextjournal.com/sdanisch/wasm-julia |title=Julia in the Browser |website=nextjournal.com |access-date=9 April 2019}}</ref><ref>{{cite web |url=https://github.com/JuliaPackaging/Yggdrasil/pull/2 |title=WebAssembly platform by tshort · Pull Request #2 · JuliaPackaging/Yggdrasil |website=GitHub |language=en |access-date=9 April 2019}}</ref><ref>{{cite web |last=Fischer |first=Keno |title=GitHub - Keno/julia-wasm: Running julia on wasm. |website=[[GitHub]] |date=22 July 2019 |url=https://github.com/Keno/julia-wasm |access-date=25 July 2019}}</ref> [[Ruby (programming language)|Ruby]]<ref>{{cite web |url=https://ruby.dj/ |title=MRuby in Your Browser |website=ruby.dj |access-date=25 July 2019}}</ref> and [[Ring (programming language)|Ring]].<ref name="InfoWorld">{{cite web |url=https://www.infoworld.com/article/3572395/ring-language-upgrade-focuses-on-webassembly.html |title=Ring language upgrade focuses on WebAssembly |author=Paul Krill |date=24 August 2020 |publisher=[[InfoWorld]]}}</ref><ref>{{cite web |url=https://ring-lang.github.io/web/tryringonline/project.html |title=Ring in web browser |access-date=17 August 2024}}</ref> |
|||
A number of systems can compile Java and other [[List of JVM languages|JVM languages]] to JavaScript and WebAssembly. These include CheerpJ,<ref>{{cite web |access-date=2023-04-27 |title=Java to WebAssembly Compiler - CheerpJ |url=https://leaningtech.com/cheerpj/}}</ref> JWebAssembly<ref>{{cite web |title=JWebAssembly |url=https://github.com/i-net-software/JWebAssembly |date=27 April 2023 |via=GitHub}}</ref> and TeaVM.<ref>{{cite web |access-date=2023-04-27 |title=TeaVM — Overview |url=https://www.teavm.org/docs/intro/overview.html |website=www.teavm.org}}</ref> [[Kotlin (programming language)|Kotlin]] supports WebAssembly directly.<ref>{{cite web |title=Bringing Kotlin to the Web |url=https://developers.googleblog.com/2023/05/bringing-kotlin-to-web.html |access-date=2023-12-11 |language=en}}</ref><ref>{{cite web |last=Deleuze |first=Sébastien |date=2023-02-13 |title=The huge potential of Kotlin/Wasm |url=https://seb.deleuze.fr/the-huge-potential-of-kotlin-wasm/ |access-date=2023-12-11 |website=seb.deleuze.fr |language=en}}</ref> |
|||
== Limitations == |
|||
[[Web browser]]s do not permit WebAssembly code to directly manipulate the [[Document Object Model]]. Wasm code must defer to [[JavaScript]] for this.{{Refn|group=note|For [[Rust (programming language)|Rust]]/Wasm development, third-party libraries can provide some of the necessary JavaScript I/O.<ref>{{Cite web|url=https://docs.rs/stdweb/*/stdweb/|title=stdweb - Rust|website=docs.rs|access-date=5 June 2019|quote=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.}}</ref><ref>{{Cite web|url=https://docs.rs/web-sys/*/web_sys/|title=web_sys - Rust|website=docs.rs|access-date=5 June 2019|quote=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.}}</ref>}} |
|||
In an October 2023 survey of developers, less than half of the 303 participants were satisfied with the state of WebAssembly. A large majority cited the need for improvement in four areas: WASI, debugging support, integration with JavaScript and browser APIs, and build tooling.<ref>{{cite web |title=The State of WebAssembly 2023 |url=https://blog.scottlogic.com/2023/10/18/the-state-of-webassembly-2023.html |publisher=Scott Logic |date=18 October 2023 |access-date=14 March 2024}}</ref> |
|||
For memory-intensive allocations in WebAssembly, there are "grave limitations that make many applications infeasible to be ''reliably'' deployed on mobile browsers [..] Currently allocating more than ~300MB of memory is not reliable on Chrome on Android without resorting to Chrome-specific workarounds, nor in Safari on iOS."<ref>{{Cite web|title=Wasm needs a better memory management story · Issue #1397 · WebAssembly/design|url=https://github.com/WebAssembly/design/issues/1397|access-date=2021-02-15|website=GitHub|language=en}}</ref> |
|||
All major browsers allow WebAssembly if Content-Security-Policy is not specified, or if "unsafe-eval" is used, but behave differently otherwise.<ref>{{Cite web|title=WebAssembly/content-security-policy|url=https://github.com/WebAssembly/content-security-policy|access-date=2021-02-17|website=GitHub|language=en}}</ref> Chrome requires "unsafe-eval",<ref>{{Cite web|title=948834 - chromium - An open-source project to help move the web forward. - Monorail|url=https://bugs.chromium.org/p/chromium/issues/detail?id=948834&can=1&q=wasm-eval|access-date=2021-02-17|website=bugs.chromium.org}}</ref><ref name="ReferenceA">{{Cite web|title=No way to use WebAssembly on Chrome without 'unsafe-eval' · Issue #7 · WebAssembly/content-security-policy|url=https://github.com/WebAssembly/content-security-policy/issues/7|access-date=2021-02-17|website=GitHub|language=en}}</ref> though a worker thread can be a workaround.<ref name="ReferenceA"/> |
|||
== Security considerations == |
== Security considerations == |
||
In June 2018, a security researcher presented the possibility of using WebAssembly to circumvent browser mitigations for [[Spectre (security vulnerability)|Spectre]] and [[Meltdown (security vulnerability)|Meltdown]] security vulnerabilities once support for [[thread (computing)|thread]]s with shared memory is added. Due to this concern, WebAssembly developers put the feature on hold.<ref name="forcepoint"/><ref name="bleeping computer">{{cite web |last1=Cimpanu |first1=Catalin |title=Changes in WebAssembly Could Render Meltdown and Spectre Browser Patches Useless |url=https://www.bleepingcomputer.com/news/security/changes-in-webassembly-could-render-meltdown-and-spectre-browser-patches-useless/ |publisher=[[Bleeping Computer]] | |
In June 2018, a security researcher presented the possibility of using WebAssembly to circumvent browser mitigations for [[Spectre (security vulnerability)|Spectre]] and [[Meltdown (security vulnerability)|Meltdown]] security vulnerabilities once support for [[thread (computing)|thread]]s with shared memory is added. Due to this concern, WebAssembly developers put the feature on hold.<ref name="forcepoint"/><ref name="bleeping computer">{{cite web |last1=Cimpanu |first1=Catalin |title=Changes in WebAssembly Could Render Meltdown and Spectre Browser Patches Useless |url=https://www.bleepingcomputer.com/news/security/changes-in-webassembly-could-render-meltdown-and-spectre-browser-patches-useless/ |publisher=[[Bleeping Computer]] |access-date=8 June 2019 |language=en-us |date=24 June 2018}}</ref><ref name="tech republic">{{cite web |last1=Sanders |first1=James |title=How opaque WebAssembly code could increase the risk of Spectre attacks online |url=https://www.techrepublic.com/article/how-opaque-webassembly-code-could-increase-the-risk-of-spectre-attacks-online/ |website=[[Tech Republic]] |access-date=9 June 2019 |language=en |date=25 June 2018}}</ref> However, in order to explore these future language extensions, Google Chrome added experimental support for the WebAssembly thread proposal in October 2018.<ref>{{cite web |last1=R |first1=Bhagyashree |title=Google Chrome 70 now supports WebAssembly threads to build multi-threaded web applications |url=https://hub.packtpub.com/google-chrome-70-now-supports-webassembly-threads-to-build-multi-threaded-web-applications/ |website=[[Packt|Packt Pub]] |access-date=9 June 2019 |date=30 October 2018}}</ref> |
||
WebAssembly has been criticized for allowing greater ease of hiding the evidence for [[malware]] writers, scammers and [[phishing]] attackers |
WebAssembly has been criticized for allowing greater ease of hiding the evidence for [[malware]] writers, scammers and [[phishing]] attackers; WebAssembly is present on the user's machine only in its compiled form, which "[makes malware] detection difficult".<ref name="virus bulletin">{{cite web |last1=Lonkar |first1=Aishwarya |last2=Chandrayan |first2=Siddhesh |title=The dark side of WebAssembly |url=https://www.virusbulletin.com/virusbulletin/2018/10/dark-side-webassembly/ |website=[[Virus Bulletin]] |access-date=8 June 2019 |date=October 2018}}</ref> Speed and the easy ability to conceal in WebAssembly have led to its use in hidden [[Cryptocurrency#Mining|crypto mining]] within the website visitor's device.<ref name="virus bulletin"/><ref name="malwarebytes">{{cite web |last1=Segura |first1=Jérôme |title=Persistent drive-by cryptomining coming to a browser near you |url=https://blog.malwarebytes.com/cybercrime/2017/11/persistent-drive-by-cryptomining-coming-to-a-browser-near-you/ |publisher=[[Malwarebytes]] |access-date=8 June 2019 |date=29 November 2017}}</ref><ref name="forcepoint">{{cite web |last1=Neumann |first1=Robert |last2=Toro |first2=Abel |title=In-browser mining: Coinhive and WebAssembly |url=https://www.forcepoint.com/blog/x-labs/browser-mining-coinhive-and-webassembly |publisher=Forcepoint |access-date=8 June 2019 |language=en |date=19 April 2018}}</ref> [[Coinhive]], a now defunct service facilitating cryptocurrency mining in website visitors' browsers, claims their "miner uses WebAssembly and runs with about 65% of the performance of a native Miner."<ref name="forcepoint" /> A June 2019 study from the [[Technische Universität Braunschweig]] analyzed the usage of WebAssembly in the Alexa top 1 million websites and found the prevalent use was for malicious crypto mining, and that malware accounted for more than half of the WebAssembly-using websites studied.<ref>{{Cite web|url=https://www.infoq.com/news/2019/10/WebAssembly-wasm-malicious-usage/|title=Recent Study Estimates That 50% of Websites Using WebAssembly Apply It for Malicious Purposes|website=InfoQ|access-date=3 November 2019}}</ref><ref>{{cite book |last1=Musch |first1=Marius |title=Detection of Intrusions and Malware, and Vulnerability Assessment |volume=11543 |pages=23–42 |last2=Wressnegger |first2=Christian |last3=Johns |first3=Martin |last4=Rieck |first4=Konrad |chapter=New Kid on the Web: A Study on the Prevalence of WebAssembly in the Wild |url=https://www.sec.cs.tu-bs.de/pubs/2019a-dimva.pdf |publisher=[[Detection of Intrusions and Malware, and Vulnerability Assessment]] |access-date=15 February 2022 |doi=10.1007/978-3-030-22038-9_2 |date=June 2019 |series=Lecture Notes in Computer Science |isbn=978-3-030-22037-2 |s2cid=184482682 |archive-date=26 July 2022 |archive-url=https://web.archive.org/web/20220726131621/https://www.sec.cs.tu-bs.de/pubs/2019a-dimva.pdf |url-status=dead }} [https://www.dimva2019.org/wp-content/uploads/sites/31/2019/06/DIMVA19-slides-2-R.pdf Slides (PDF)] {{Webarchive|url=https://web.archive.org/web/20191103054140/https://www.dimva2019.org/wp-content/uploads/sites/31/2019/06/DIMVA19-slides-2-R.pdf |date=3 November 2019 }}</ref> An April 2021 study from [[University of Stuttgart|Universität Stuttgart]] found that since then crypto mining has been marginalized, falling to below 1% of all WebAssembly modules gathered from a wide range of sources, also including the Alexa top 1 million websites.<ref>Aaron Hilbig, Daniel Lehmann, and Michael Pradel (April 2021). "An Empirical Study of Real-World WebAssembly Binaries: Security, Languages, Use Cases." (Archived April 2021) https://software-lab.org/publications/www2021.pdf</ref> <!-- ORIGINAL URL WAS - DON'T KNOW HOW TO DO ARCHIVE-URL FOR CHAPTER: chapter-url=https://www.tu-braunschweig.de/Medien-DB/ias/pubs/2019-dimva.pdf --> |
||
As WebAssembly supports only structured [[control flow]], it is amenable toward security verification techniques including [[symbolic execution]].<ref>{{Cite book|last=Watt|first=Conrad|title=Proceedings of the 7th ACM SIGPLAN International Conference on Certified Programs and Proofs |chapter=Mechanising and verifying the WebAssembly specification |date=2018-01-08|chapter-url=https://dl.acm.org/doi/10.1145/3167082|series=CPP 2018|language=en|location=Los Angeles CA USA|publisher=ACM|pages=53–65|doi=10.1145/3167082|isbn=978-1-4503-5586-5|s2cid=9401691|url=https://www.repository.cam.ac.uk/handle/1810/274174 }}</ref> |
|||
{{Anchor|Beyond the Browser}} |
|||
== |
== Performance== |
||
Benchmark results vary between implementations and between themselves. Performance was benchmarked early to be around 91% (i.e., 10% slower) for running code, not including load/instantiation time<ref>{{Cite book|last=Arjun|first=Jangda, Abhinav Powers, Bobby Berger, Emery Guha|url=http://worldcat.org/oclc/1106328738|title=Not So Fast: Analyzing the Performance of WebAssembly vs. Native Code|date=2019-01-25|oclc=1106328738}}</ref> or more recently between 100% and 33% of native rates,<ref>{{cite web |last1=Denis |first1=Frank |title=Performance of WebAssembly runtimes in 2023 |url=https://00f.net/2023/01/04/webassembly-benchmark-2023/ |website=00f.net |access-date=6 December 2024}}</ref> and 120% of JavaScript (i.e. 20% faster).<ref>{{cite book |last1=De Macedo |first1=Joao |last2=Abreu |first2=Rui |last3=Pereira |first3=Rui |last4=Saraiva |first4=Joao |chapter=WebAssembly versus JavaScript: Energy and Runtime Performance |title=2022 International Conference on ICT for Sustainability (ICT4S) |date=June 2022 |pages=24–34 |doi=10.1109/ICT4S55073.2022.00014|hdl=1822/90291 |isbn=978-1-6654-8286-8 }}</ref>{{refn|group=note|A personal web page of 2024 reported a benchmark of a simple game application on a mobile phone found between 110% and 190% (i.e. faster) of native rates depending on the browser.<ref>{{cite web |last1=Turner |first1=Aaron |title=WebAssembly Is Fast: A Real-World Benchmark of WebAssembly vs. ES6 |url=https://medium.com/@torch2424/webassembly-is-fast-a-real-world-benchmark-of-webassembly-vs-es6-d85a23f8e193}}</ref>}} However, a 2023 paper benchmarking the purported [[IoT]] energy-saving improvements using WebAsm compared to native C, Rust, Go, and JavaScript found no conclusive results for choosing WebAsm.<ref>{{cite journal |last1=Wagner |first1=Linus |last2=Mayer |first2=Maximilian |last3=Marino |first3=Andrea |last4=Soldani Nezhad |first4=Alireza |last5=Zwaan |first5=Hugo |last6=Malavolta |first6=Ivano |title=On the Energy Consumption and Performance of WebAssembly Binaries across Programming Languages and Runtimes in IoT |journal=Proceedings of the 27th International Conference on Evaluation and Assessment in Software Engineering |date=14 June 2023 |pages=72–82 |doi=10.1145/3593434.3593454|isbn=979-8-4007-0044-6 }}</ref> |
|||
The general standards provide core specifications for JavaScript and Web embedding.<ref name=":0" /> |
|||
A 2021 study suggested that WebAssembly, in the versions they tested at that time, was well faster than JavaScript in certain cases and browsers only, such as running a complex function on a small file, e.g. processing a graphics file, but that JavaScript had some optimizations available, e.g. JIT, that WebAssembly did not.<ref>{{cite book |last1=Yan |first1=Yutian |last2=Tu |first2=Tengfei |last3=Zhao |first3=Lijian |last4=Zhou |first4=Yuchen |last5=Wang |first5=Weihang |title=Proceedings of the 21st ACM Internet Measurement Conference |chapter=Understanding the performance of webassembly applications |date=2 November 2021 |pages=533–549 |doi=10.1145/3487552.3487827 |isbn=978-1-4503-9129-0 |chapter-url=https://weihang-wang.github.io/slides/Yan-IMC21.pptx}}</ref> |
|||
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.<ref name="nonweb">{{cite web |url=https://webassembly.org/docs/non-web/ |title=Non-Web Embeddings |work=WebAssembly |accessdate=2019-05-15}}</ref><ref name="nonwebsrc">{{cite web |url=https://github.com/WebAssembly/design/blob/master/NonWeb.md |title=Non-Web Embeddings |work=[[GitHub]] / WebAssembly |accessdate=2019-05-15}}</ref> |
|||
Benchmarking has revealed several other pain-points for WebAssembly, such as poor performance because of no direct access to the DOM,{{refn|group=note|"WebAssembly provides no access to the surrounding environment other than via the JavaScript API described in the JS API specification."<ref>{{cite web |title=WebAssembly Web API |url=https://webassembly.github.io/spec/web-api/index.html#security-considerations |website=webassembly.github.io}}</ref>}} which are being addressed or may be addressed in the future.<ref>{{cite web |last1=Kambale |first1=Enoch |title=WebAssembly in 2024: Promises, Challenges, and the Road Ahead |url=https://blog.enkambale.com/webassembly-2024-state-of-wasm/ |website=blog.enkambale.com |access-date=6 December 2024 |language=en}}</ref> |
|||
{{anchor|WASI}}WebAssembly System Interface (WASI) is an [[application binary interface|ABI]] designed by [[Mozilla]] intended to define a simpler ABI for WebAssembly that can be used in any platform.<ref name="WASI">{{cite web |url=https://github.com/WebAssembly/WASI |title=WebAssembly System Interface Repo |work=[[GitHub]] / WebAssembly}}</ref> There are also a few other proposed ABI APIs.<ref name="reference-sysroot">{{cite web |url=https://github.com/WebAssembly/reference-sysroot |title=reference-sysroot Repo |work=[[GitHub]] / WebAssembly}}</ref><ref name="wasm-c-api">{{cite web |url=https://github.com/WebAssembly/wasm-c-api |title=wasm-c-api Repo |work=[[GitHub]] / WebAssembly}}</ref> |
|||
== WASI<span class="anchor" id="Beyond the Browser"></span> ==<!-- This section must eventually be merged into Implementations' sub section called like "host environments" as the WASI interface is (AFAIK) describes how some features must be provided by the host to the VM's executed .wasm programs. --> |
|||
== Specification{{Anchor|Features}}== |
|||
{{anchor|WASI}}WebAssembly System Interface (WASI) is a simple interface ([[application binary interface|ABI]] and [[application programming interface|API]]) designed by [[Mozilla]] intended to be portable to any platform.<ref name="WASI">{{cite web |url=https://github.com/WebAssembly/WASI |title=WebAssembly System Interface Repo |work=[[GitHub]] / WebAssembly|date=10 February 2020 }}</ref> It provides [[POSIX]]-like features like file I/O constrained by [[capability-based security]].<ref>{{cite web |title=Additional background on Capabilities |url=https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-capabilities.md |website=GitHub |date=4 March 2022 |publisher=bytecodealliance |language=en}}</ref><ref>{{cite web |title=Standardizing WASI: A system interface to run WebAssembly outside the web – Mozilla Hacks - the Web developer blog |url=https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/ |website=Mozilla Hacks – the Web developer blog}}</ref> There are additional proposed ABI/APIs.<ref name="reference-sysroot">{{cite web |url=https://github.com/WebAssembly/reference-sysroot |title=reference-sysroot Repo |work=[[GitHub]] / WebAssembly|date=12 January 2020 }}</ref><ref name="wasm-c-api">{{cite web |url=https://github.com/WebAssembly/wasm-c-api |title=wasm-c-api Repo |work=[[GitHub]] / WebAssembly|date=3 February 2020 }}</ref> |
|||
WASI is influenced by [[Capsicum (Unix)#CloudABI|CloudABI]] and [[Capsicum (Unix)|Capsicum]].{{According to whom|date=September 2024}} |
|||
{{interlanguage link|Solomon Hykes|fr}}, a co-founder of [[Docker (software)|Docker]], wrote in 2019, "If WASM+WASI existed in 2008, we wouldn't have needed to create Docker. That's how important it is. WebAssembly on the server is the future of computing."<ref>{{Cite web |last=Hykes |first=Solomon |date=March 27, 2019 |title=Solomon Hykes on X |url=https://x.com/solomonstre/status/1111004913222324225 |access-date=September 29, 2024 |website=[[Twitter]]}}</ref> |
|||
== Specification<span class="anchor" id="Features"></span>== |
|||
=== Host environment === |
|||
The general standard provides core specifications for the JavaScript API and details on embedding.<ref name=":0" /> |
|||
=== Virtual machine === |
=== Virtual machine === |
||
Wasm code (binary |
Wasm code (binary code, i.e. bytecode) is intended to be run on a [[software portability|portable]] virtual [[stack machine]] (VM).<ref name="stack machine" /> The VM is designed to be faster to parse and execute than JavaScript and to have compact code representation.<ref name="github.com" /> Any external functionality (like [[system call|syscalls]]) that may be expected by Wasm binary code is not stipulated by the standard. It rather provides a way to deliver interfacing via modules by the host environment that the VM runs in.<ref>{{Cite web|title=Portability - WebAssembly|url=https://webassembly.org/docs/portability/#assumptions-for-efficient-execution|access-date=2020-07-28|website=webassembly.org}}</ref><ref name=":1" /> |
||
=== Wasm program === |
=== Wasm program === |
||
A Wasm program is designed |
A Wasm program is designed as a separate module containing collections of various Wasm-defined values and program type definitions. These are provided in either binary or textual format (see below) that have a common structure.<ref>{{Cite web|url=https://webassembly.github.io/spec/core/syntax/conventions.html|title=Conventions — WebAssembly 1.0|website=webassembly.github.io|access-date=12 November 2019}}</ref> Such a module may provide a start function that is executed upon instantiation of a wasm binary. |
||
==== Instruction set ==== |
==== Instruction set ==== |
||
The core standard for binary format of |
The core standard for the binary format of a Wasm program defines an [[instruction set architecture]] (ISA) consisting of specific [[opcode|binary encodings]] of types of operations which are executed by the VM (without specifying how exactly they must be executed).<ref>{{Cite web|url=https://webassembly.github.io/spec/core/intro/introduction.html?highlight=isa#scope|title=Introduction — WebAssembly 1.0|website=webassembly.github.io|access-date=17 May 2019}}</ref> The list of instructions includes standard memory load/store instructions, numeric, parametric, [[Control flow|control of flow]] [[Instruction set architecture|instruction types]] and Wasm-specific variable instructions.<ref>{{Cite web|url=https://webassembly.github.io/spec/core/syntax/instructions.html|title=Instructions — WebAssembly 1.0|website=webassembly.github.io|access-date=12 November 2019}}</ref> |
||
The number of opcodes used in the original standard (MVP) was a bit fewer than 200 of the 256 possible opcodes. Subsequent versions of WebAssembly pushed the number of opcodes a bit over 200. The [[WebAssembly SIMD]] proposal (for parallel processing) introduces an alternate opcode prefix (0xfd) for [[128-bit computing|128-bit]] SIMD. The concatenation of the SIMD prefix, plus an opcode that is valid after the SIMD prefix, forms a SIMD opcode. The SIMD opcodes bring an additional 236 instructions for the "minimum viable product" (MVP) SIMD capability (for a total of around 436 instructions).<ref> |
|||
{{ |
|||
Cite web |
|||
| url=https://github.com/WebAssembly/simd/pull/452 |
|||
| title=Final opcodes by tlively · Pull Request #452 · WebAssembly/simd · GitHub |
|||
| last=Lively |
|||
| first=Thomas |
|||
| date=2021-02-19 |
|||
| orig-date=Pull Request opened on 2021-02-05 |
|||
| publisher=Bytecode Alliance |
|||
| via=[[GitHub]] |
|||
| access-date=2021-05-12 |
|||
}} |
|||
</ref><ref> |
|||
{{ |
|||
Cite web |
|||
| url=https://github.com/bytecodealliance/wasm-tools/blob/b5c3d98e40590512a3b12470ef358d5c7b983b15/crates/wast/src/ast/expr.rs |
|||
| title=File wasm-tools/expr.rs at b5c3d98e40590512a3b12470ef358d5c7b983b15 · bytecodealliance/wasm-tools · GitHub |
|||
| last=Delendik |
|||
| first=Yury |
|||
| date=2021-02-19 |
|||
| orig-date=SIMD changes committed on 2021-02-19 |
|||
| publisher=Bytecode Alliance |
|||
| via=[[GitHub]] |
|||
| access-date=2021-05-12 |
|||
}} |
|||
</ref> Those instructions, the "finalized opcodes"<ref>{{Cite web|title=Update interpreter and text with finalized opcodes by ngzhian · Pull Request #486 · WebAssembly/simd|url=https://github.com/WebAssembly/simd/pull/486|access-date=2021-05-14|website=GitHub|language=en}}</ref> are enabled by default across Google's V8 (in Google Chrome), the SpiderMonkey engine in Mozilla Firefox, and the JavaScriptCore engine in Apple's Safari<ref>{{Cite web|title=WebAssembly/simd|url=https://github.com/WebAssembly/simd|access-date=2021-05-14|website=GitHub|language=en}}</ref> and there are also some additional proposal for instructions for later "post SIMD MVP", and there's also a separate "relaxed-simd" proposal on the table.<ref>{{Citation|title=WebAssembly/relaxed-simd|date=2021-05-03|url=https://github.com/WebAssembly/relaxed-simd|publisher=WebAssembly|access-date=2021-05-14}}</ref> |
|||
These SIMD opcodes are also portable and translate to native instruction sets like x64 and ARM. In contrast, neither Java's [[Java bytecode instruction listings|JVM]] nor [[List of CIL instructions|CIL]] support SIMD, at their ''opcode level'', i.e. in the standard; both do have some parallel APIs which provide SIMD speedup. There is an extension for Java adding [[intrinsic function|intrinsic]]s for x64 SIMD,<ref>{{Cite web|title=How we made the JVM 40x faster|url=https://astojanov.github.io/blog/2017/12/20/scala-simd.html<!--|quote=support for all 5912 Intel SIMD intrinsics from MMX to AVX-512.-->|access-date=2021-02-17|website=astojanov.github.io}}</ref> that isn't portable, i.e. not usable on ARM or smartphones. Smartphones can support SIMD by calling assembly code with SIMD, and C# has similar support. |
|||
==== Code representation ==== |
==== Code representation ==== |
||
In March 2017, the WebAssembly Community Group reached consensus on the initial (MVP) binary format, JavaScript API, and reference interpreter.<ref name="Roadmap" /> It defines a WebAssembly binary format, which is not designed to be used by humans, as well as a human-readable |
In March 2017, the WebAssembly Community Group reached consensus on the initial (MVP) binary format, JavaScript API, and reference interpreter.<ref name="Roadmap" /> It defines a WebAssembly binary format ({{code|.wasm}}), which is not designed to be used by humans, as well as a human-readable WebAssembly text format ({{code|.wat}}) that resembles a cross between S-expressions and traditional assembly languages. |
||
The table below shows an example of a [[factorial]] function written in [[C (programming language)|C]] and its corresponding WebAssembly code after compilation, shown both in {{mono|.wat}} text format (a human-readable textual representation of WebAssembly) and in {{mono|.wasm}} binary format (the raw [[bytecode]], expressed below in [[hexadecimal]]), that is executed by a Web browser or run-time environment that supports WebAssembly. |
|||
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:<ref name="Text Format" /> |
|||
{| class="wikitable" |
{| class="wikitable" |
||
|+C source code and corresponding WebAssembly |
|||
|- |
|- |
||
!scope="col"|C source code |
|||
! [[C (programming language)|C]] input source !! Linear assembly bytecode<br/> ([[intermediate representation]]) !! Wasm binary encoding<br/> (hexadecimal bytes) |
|||
!scope="col"|WebAssembly {{mono|.wat}} text format |
|||
!scope="col"|WebAssembly {{mono|.wasm}} binary format |
|||
|- style="vertical-align:top" |
|- style="vertical-align:top" |
||
| |
| |
||
< |
<syntaxhighlight lang="c"> |
||
int factorial(int n) { |
int factorial(int n) { |
||
if (n == 0) |
if (n == 0) |
||
Line 94: | Line 216: | ||
return n * factorial(n-1); |
return n * factorial(n-1); |
||
} |
} |
||
</syntaxhighlight> |
|||
</source> |
|||
|| |
|| |
||
< |
<syntaxhighlight lang="wat"> |
||
(func (param i64) (result i64) |
|||
get_local 0 |
|||
local.get 0 |
|||
i64.eqz |
|||
i64.eqz |
|||
i64 |
if (result i64) |
||
i64.const 1 |
|||
else |
|||
else |
|||
get_local 0 |
|||
local.get 0 |
|||
local.get 0 |
|||
i64. |
i64.const 1 |
||
i64.sub |
|||
call 0 |
|||
i64.mul |
|||
end |
|||
end) |
|||
</source> |
|||
</syntaxhighlight> |
|||
|| |
|| |
||
< |
<syntaxhighlight lang="text"> |
||
00 61 73 6D 01 00 00 00 |
|||
01 06 01 60 01 7E 01 7E |
|||
03 02 01 00 |
|||
0A 17 01 |
|||
15 00 |
|||
20 00 |
20 00 |
||
50 |
50 |
||
Line 124: | Line 252: | ||
7E |
7E |
||
0B |
0B |
||
0B |
|||
</source> |
|||
</syntaxhighlight> |
|||
|} |
|} |
||
All integer constants are encoded using a space-efficient, variable-length [[LEB128]] encoding.<ref name=wasmint>{{cite web |
|||
The WebAssembly text format can also be written in a folded format using [[s-expression]]s. This format is purely [[syntactic sugar]] and has no behavioral differences with the linear format.<ref name="Folded Instructions"/> An example is shown below: |
|||
| url = https://webassembly.github.io/spec/core/binary/values.html#integers |
|||
| title = WebAssembly Specification Release 1.0 |
|||
| access-date = 13 January 2020 |
|||
| author = WebAssembly Community Group |
|||
|date=January 2020 |
|||
}}</ref> |
|||
The WebAssembly text format is more canonically written in a folded format using [[S-expression]]s. For instructions and expressions, this format is purely [[syntactic sugar]] and has no behavioral differences with the linear format.<ref name="Folded Instructions"/> Through {{code|wasm2wat}}, the code above decompiles to: |
|||
<source lang="lisp"> |
|||
<syntaxhighlight lang="wat"> |
|||
(module |
(module |
||
( |
(type $t0 (func (param i64) (result i64))) |
||
(func ( |
(func $f0 (type $t0) (param $p0 i64) (result i64) |
||
(if $I0 (result i64) ;; $I0 is an unused label name |
|||
(f64.mul |
|||
( |
(i64.eqz |
||
(local.get $p0)) ;; the name $p0 is the same as 0 here |
|||
(get_local $0) |
|||
(then |
|||
( |
(i64.const 1)) |
||
(else |
|||
(i64.mul |
|||
) |
|||
(local.get $p0) |
|||
) |
|||
(call $f0 ;; the name $f0 is the same as 0 here |
|||
</source> |
|||
(i64.sub |
|||
(local.get $p0) |
|||
(i64.const 1)))))))) |
|||
</syntaxhighlight> |
|||
A module is implicitly generated by the compiler. The function is referenced by an entry of the type table in the binary, hence a type section and the {{code|type}} emitted by the decompiler.<ref>{{cite web |title=Modules (Binary) |url=https://webassembly.github.io/spec/core/syntax/modules.html |website=WebAssembly 1.0}}</ref> The compiler and decompiler can be accessed online.<ref>{{cite web |title=WebAssembly Binary Toolkit (wabt) demos |url=https://webassembly.github.io/wabt/demo/ |website=webassembly.github.io}}</ref> |
|||
== |
== See also == |
||
* [[Architecture Neutral Distribution Format]] (ANDF) |
|||
* {{Cite journal|first1=Andreas|last1=Haas|first2=Andreas|last2=Rossberg|first3=Derek L.|last3=Schuff|first4=Ben L.|last4=Titzer|first5=Dan|last5=Gohman|first6=Luke|last6=Wagner|first7=Alon|last7=Zakai|first8=JF|last8=Bastien|first9=Michael|last9=Holman|date=June 2017|title=Bringing the web up to speed with WebAssembly|url=https://dl.acm.org/ft_gateway.cfm?id=3062363&type=pdf|journal=Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation|publisher=Association for Computing Machinery|volume=|pages=185–200|doi=10.1145/3062341.3062363|via=|isbn=9781450349888}} |
|||
* [[UNCOL]] |
|||
* {{Cite journal|last=Watt|first=Conrad|date=2018|title=Mechanising and Verifying the WebAssembly Specification|url=https://www.cl.cam.ac.uk/~caw77/papers/mechanising-and-verifying-the-webassembly-specification.pdf|journal=ACM SIGPLAN International Conference on Certified Programs and Proofs|publisher=ACM|volume=7|pages=53–65|doi=10.1145/3167082|via=|isbn=9781450355865}} |
|||
* [[Java bytecode]] |
|||
* [[Common Language Runtime]] |
|||
* [[LLVM]] |
|||
* [[Compiler|Compilation]] |
|||
* [[Porting|Software portability]] |
|||
== Notes == |
== Notes == |
||
Line 152: | Line 300: | ||
== References == |
== References == |
||
{{reflist|30em|refs= |
{{reflist|30em|refs= |
||
<ref name="techcrunch2015">{{Cite news|url=https://techcrunch.com/2015/06/17/google-microsoft-mozilla-and-others-team-up-to-launch-webassembly-a-new-binary-format-for-the-web/|title=Google, Microsoft, Mozilla And Others Team Up To Launch WebAssembly, A New Binary Format For The Web|last=Lardinois|first=Frederic|date=2015 |
<ref name="techcrunch2015">{{Cite news|url=https://techcrunch.com/2015/06/17/google-microsoft-mozilla-and-others-team-up-to-launch-webassembly-a-new-binary-format-for-the-web/|title=Google, Microsoft, Mozilla And Others Team Up To Launch WebAssembly, A New Binary Format For The Web|last=Lardinois|first=Frederic|date=17 June 2015|work=TechCrunch|access-date=24 December 2017|language=en}}</ref> |
||
<ref name="ars">{{cite web |first=Peter |last=Bright |url=https://arstechnica.com/information-technology/2015/06/the-web-is-getting-its-bytecode-webassembly/|title=The Web is getting its bytecode: WebAssembly|work=[[Ars Technica]] |publisher=[[Condé Nast]] |date=18 June 2015}}</ref> |
<ref name="ars">{{cite web |first=Peter |last=Bright |url=https://arstechnica.com/information-technology/2015/06/the-web-is-getting-its-bytecode-webassembly/|title=The Web is getting its bytecode: WebAssembly|work=[[Ars Technica]] |publisher=[[Condé Nast]] |date=18 June 2015}}</ref> |
||
<ref name="bytecode">{{Cite news|url=https://blog.mozilla.org/press/2019/11/new-bytecode-alliance-brings-the-security-ubiquity-and-interoperability-of-the-web-to-the-world-of-pervasive-computing/|title=New Bytecode Alliance Brings the Security, Ubiquity, and Interoperability of the Web to the World of Pervasive Computing|date=12 November 2019|work=Mozilla|access-date=27 May 2019|language=en}}</ref> |
|||
<ref name=AcceleratingWeb>{{cite web|url=https://zendev.com/2018/06/26/webassembly-accelerating-future-web-development.html |title=How WebAssembly is Accelerating the Future of Web Development |last=Ball | first=Kevin |date=June 26, 2018 |accessdate=2018-10-22 |archive-url=https://web.archive.org/web/20190212141715/https://zendev.com/2018/06/26/webassembly-accelerating-future-web-development.html |archive-date=2019-02-12}}</ref> |
|||
<ref name= |
<ref name=AcceleratingWeb>{{cite web|url=https://zendev.com/2018/06/26/webassembly-accelerating-future-web-development.html |title=How WebAssembly is Accelerating the Future of Web Development |last=Ball | first=Kevin |date=26 June 2018 |access-date=22 October 2018 |archive-url=https://web.archive.org/web/20190212141715/https://zendev.com/2018/06/26/webassembly-accelerating-future-web-development.html |archive-date=12 February 2019}}</ref> |
||
<ref name= |
<ref name=Implementations>{{cite web |url=https://github.com/appcypher/awesome-wasm-langs |title=Awesome WebAssembly Languages |website=[[GitHub]] |date=26 June 2018 |access-date=15 February 2022}}</ref> |
||
<ref name=" |
<ref name="stack machine">{{cite web|url=https://github.com/WebAssembly/design/blob/main/Rationale.md#why-a-stack-machine|title=Design Rationale|date=1 October 2016|work=[[GitHub]] / WebAssembly / design}}</ref> |
||
<ref name=" |
<ref name="github.com">{{cite web|url=https://github.com/WebAssembly/design/blob/main/HighLevelGoals.md|title=WebAssembly High-Level Goals|date=11 December 2015|work=[[GitHub]] / WebAssembly / design}}</ref> |
||
<ref name="PNaCl">{{Cite web|url=https://www.infoq.com/news/2017/05/pnacl-webassembly-google|title=Google Is to Remove Support for PNaCl|last=Avram|first=Abel|date=31 May 2017|website=InfoQ|access-date=22 December 2017}}</ref> |
|||
<ref name="initial implementation">{{cite web|url=https://www.2ality.com/2015/06/web-assembly.html|title=WebAssembly: a binary format for the web|work=②ality – JavaScript and more|date=18 June 2015}}</ref> |
<ref name="initial implementation">{{cite web|url=https://www.2ality.com/2015/06/web-assembly.html|title=WebAssembly: a binary format for the web|work=②ality – JavaScript and more|date=18 June 2015}}</ref> |
||
Line 176: | Line 326: | ||
<ref name="Edge">{{Cite web|url=https://blogs.windows.com/msedgedev/2016/03/15/previewing-webassembly-experiments/|title=Previewing WebAssembly experiments in Microsoft Edge|last=Zhu|first=Limin|date=15 March 2016|website=Microsoft Edge dev blog}}</ref> |
<ref name="Edge">{{Cite web|url=https://blogs.windows.com/msedgedev/2016/03/15/previewing-webassembly-experiments/|title=Previewing WebAssembly experiments in Microsoft Edge|last=Zhu|first=Limin|date=15 March 2016|website=Microsoft Edge dev blog}}</ref> |
||
<ref name="MVP">{{Cite news|url=https://www.infoworld.com/article/3176681/|title=WebAssembly is now ready for browsers to use|last=Krill|first=Paul|date=2017 |
<ref name="MVP">{{Cite news|url=https://www.infoworld.com/article/3176681/|title=WebAssembly is now ready for browsers to use|last=Krill|first=Paul|date=6 March 2017|work=InfoWorld|access-date=23 December 2017|language=en}}</ref> |
||
<ref name=" |
<ref name="canIuse.com">{{Cite web |title=WebAssembly {{!}} Can I use... Support tables for HTML5, CSS3, etc |url=https://caniuse.com/wasm |access-date=2024-03-01 |website=canIuse.com}}</ref> |
||
<ref name="in browsers">{{Cite web|url=https://blog.mozilla.org/blog/2017/11/13/webassembly-in-browsers/|title=WebAssembly support now shipping in all major browsers|website=The Mozilla Blog|language=en-US|access-date= |
<ref name="in browsers">{{Cite web|url=https://blog.mozilla.org/blog/2017/11/13/webassembly-in-browsers/|title=WebAssembly support now shipping in all major browsers|website=The Mozilla Blog|language=en-US|access-date=21 November 2017}}</ref> |
||
<ref name="Edge16">{{Cite web|url=https://blogs.windows.com/msedgedev/2017/10/31/optimizations-webassembly-sharedarraybuffer-atomics-edgehtml-16/|title=Introducing new JavaScript optimizations, WebAssembly, SharedArrayBuffer, and Atomics in EdgeHTML 16|website=Microsoft Edge Dev Blog|language=en-US|access-date= |
<ref name="Edge16">{{Cite web|url=https://blogs.windows.com/msedgedev/2017/10/31/optimizations-webassembly-sharedarraybuffer-atomics-edgehtml-16/|title=Introducing new JavaScript optimizations, WebAssembly, SharedArrayBuffer, and Atomics in EdgeHTML 16|website=Microsoft Edge Dev Blog|language=en-US|access-date=21 November 2017|date=31 October 2017}}</ref> |
||
<ref name="ars2015">{{Cite news|url=https://arstechnica.com/information-technology/2015/06/the-web-is-getting-its-bytecode-webassembly/|title=The Web is getting its bytecode: WebAssembly|last=Bright|first=Peter|date= |
<!--<ref name="ars2015">{{Cite news|url=https://arstechnica.com/information-technology/2015/06/the-web-is-getting-its-bytecode-webassembly/|title=The Web is getting its bytecode: WebAssembly|last=Bright|first=Peter|date=18 June 2015|work=Ars Technica|access-date=23 December 2017|language=en-us}}</ref> --> |
||
<ref name="Rust">{{Cite news|url=https://www.infoworld.com/article/3239129/|title=Direct WebAssembly compilation comes to Rust language|last=Krill|first=Paul|date=2017 |
<ref name="Rust">{{Cite news|url=https://www.infoworld.com/article/3239129/|title=Direct WebAssembly compilation comes to Rust language|last=Krill|first=Paul|date=29 November 2017|work=InfoWorld|access-date=24 December 2017|language=en}}</ref> |
||
<ref name="next">{{Cite news|url=https://www.techworld.com.au/article/629123/|title=What's next for WebAssembly: GC, threads, debugging|last=Krill|first=Paul|date= |
<!-- <ref name="next">{{Cite news|url=https://www.techworld.com.au/article/629123/|title=What's next for WebAssembly: GC, threads, debugging|last=Krill|first=Paul|date=26 October 2017|work=TechWorld|access-date=24 December 2017}}</ref> --> |
||
<ref name="Roadmap">{{Cite web|url=https://webassembly.org/roadmap/|title=Roadmap |website=WebAssembly |date=March 2017}}</ref> |
<ref name="Roadmap">{{Cite web|url=https://webassembly.org/roadmap/|title=Roadmap |website=WebAssembly |date=March 2017}}</ref> |
||
<ref name="W3C-WD2018">{{cite web |url=https://www.w3.org/blog/news/archives/6838|title=WebAssembly First Public Working Drafts|publisher=W3C|date= 15 February 2018|access-date=20 April 2018}}</ref> |
|||
<ref name="Text Format">{{cite web|author1=jfbastien |author2=rossberg-chromium |author3=kripken |author4=titzer |author5=s3ththompson |author6=sunfishcode |author7=lukewagner |author8=flagxor |author9=enricobacis |author10=c3d |author11=binji |author12=andrewosh |date=9 March 2017 |title=Text Format |website=WebAssembly/design |publisher=GitHub |url=https://github.com/WebAssembly/design/blob/master/TextFormat.md }}</ref> |
|||
<ref name="W3C-CSWD2018">{{cite web |url=https://www.w3.org/TR/2018/WD-wasm-core-1-20180215/|title=WebAssembly Core Specification|publisher=W3C|date= 15 February 2018|access-date=20 April 2018}}</ref> |
|||
<ref name="W3C- |
<ref name="W3C-JIWD2018">{{cite web |url=https://www.w3.org/TR/2018/WD-wasm-js-api-1-20180215/|title=WebAssembly JavaScript Interface|publisher=W3C|date= 15 February 2018|access-date=20 April 2018}}</ref> |
||
<ref name="W3C- |
<ref name="W3C-WAWD2018">{{cite web |url=https://www.w3.org/TR/2018/WD-wasm-web-api-1-20180215/|title=WebAssembly Web API|publisher=W3C|date= 15 February 2018|access-date=20 April 2018}}</ref> |
||
<ref name="W3C-JIWD2018">{{cite web |url=https://www.w3.org/TR/2018/WD-wasm-js-api-1-20180215/|title=WebAssembly JavaScript Interface|publisher=W3C|date= February 15, 2018|access-date=April 20, 2018}}</ref> |
|||
<ref name="W3C-WAWD2018">{{cite web |url=https://www.w3.org/TR/2018/WD-wasm-web-api-1-20180215/|title=WebAssembly Web API|publisher=W3C|date= February 15, 2018|access-date=April 20, 2018}}</ref> |
|||
<ref name="Folded Instructions">{{cite web|url=https://webassembly.github.io/spec/core/text/instructions.html#folded-instructions|title=Folded instructions|work=[[GitHub]]}} / WebAssembly / spec</ref> |
<ref name="Folded Instructions">{{cite web|url=https://webassembly.github.io/spec/core/text/instructions.html#folded-instructions|title=Folded instructions|work=[[GitHub]]}} / WebAssembly / spec</ref> |
||
Line 207: | Line 355: | ||
|publisher = GitHub |
|publisher = GitHub |
||
|source= WebAssembly/design |
|source= WebAssembly/design |
||
|documentURL= https://github.com/WebAssembly/design/blob/ |
|documentURL= https://github.com/WebAssembly/design/blob/main/TextFormat.md |
||
|license statement URL= https://github.com/WebAssembly/design/blob/ |
|license statement URL= https://github.com/WebAssembly/design/blob/main/LICENSE |
||
|license= Apache License 2.0 |
|license= Apache License 2.0 |
||
}} |
}} |
||
== Demo == |
|||
* Widgets demo: [http://nowsmartsoft.atwebpages.com/demo1/index.html] with NWSTK |
|||
* 3D mountain geometry synthesis demo: [http://nowsmartsoft.atwebpages.com/demo_Mountain/index.html] with NWSTK |
|||
* Demo for loading and drawing a [[JPEG|jpg]] file: [http://nowsmartsoft.atwebpages.com/demo2/index.html] with NWSTK |
|||
== External links == |
== External links == |
||
{{sisterlinks|d=Q20155677|c=Category:WebAssembly|n=no|b=no|s=no|wikt=no|species=no|q=no|v=no|voy=no|m=no|mw=no}} |
|||
* {{Official website}} |
* {{Official website}} |
||
* [https://www.w3.org/community/webassembly/ W3C Community Group] |
* [https://www.w3.org/community/webassembly/ W3C Community Group] |
||
* [https://github. |
* [https://webassembly.github.io/spec/core/ WebAssembly Specification] |
||
* {{Citation|url=https://developer.mozilla.org/en-US/docs/WebAssembly|title=WebAssembly|website=MDN Web Docs|language=en-US}}{{snd}} with info on browser compatibility and specifications (WebAssembly JavaScript API) |
* [https://github.com/WebAssembly/design WebAssembly Design Documents] |
||
* {{Citation|url=https://developer.mozilla.org/en-US/docs/WebAssembly|title=WebAssembly|website=MDN Web Docs|date=16 April 2024 |language=en-US}}{{snd}} with info on browser compatibility and specifications (WebAssembly JavaScript API) |
|||
* [https://www.youtube.com/watch?v=R9wn99Xheq4 <!--GOTO 2017 • --> WebAssembly: What and What Next?] at [[YouTube]] |
|||
{{W3C Standards}} |
|||
{{Web browsers|fsp}} |
{{Web browsers|fsp}} |
||
{{Web interfaces}} |
{{Web interfaces}} |
||
Line 229: | Line 374: | ||
[[Category:Assembly languages]] |
[[Category:Assembly languages]] |
||
[[Category: |
[[Category:Internet properties established in 2015]] |
||
[[Category:World Wide Web Consortium standards]] |
|||
[[Category:Web programming]] |
[[Category:Web programming]] |
||
[[Category: |
[[Category:Bytecodes]] |
||
[[Category:Programming languages created in 2015]] |
Latest revision as of 14:08, 27 December 2024
Paradigm | structured; stack machine[1] |
---|---|
Designed by | W3C |
Developer | |
First appeared | March 2017 |
OS | Platform independent |
License | Apache License 2.0 |
Filename extensions |
|
Website | webassembly |
Influenced by | |
WebAssembly (Wasm) defines a portable binary-code format and a corresponding text format for executable programs[2] as well as software interfaces for facilitating communication between such programs and their host environment.[3][4][5][6]
The main goal of WebAssembly is to facilitate high-performance applications on web pages, but it is also designed to be usable in non-web environments.[7] It is an open standard[8][9] intended to support any language on any operating system,[10] and in practice many of the most popular languages already have at least some level of support.
Announced in 2015World Wide Web Consortium recommendation on 5 December 2019[11][12][13] and it received the Programming Languages Software Award from ACM SIGPLAN in 2021.[14] The World Wide Web Consortium (W3C) maintains the standard with contributions from Mozilla, Microsoft, Google, Apple, Fastly, Intel, and Red Hat.[15][16]
and first released in March 2017 , WebAssembly became aHistory
[edit]The name WebAssembly is intended to seem synonymous with that of the assembly language. The name suggests bringing assembly-like programming to the Web, where it will be executed client-side — by the website-user's computer via the user's web browser. To accomplish this, WebAssembly must be much more hardware-independent than a true assembly language.
WebAssembly was first announced in 2015,[17] and the first demonstration was executing Unity's Angry Bots in Firefox,[18] Google Chrome,[19] and Microsoft Edge.[20] The precursor technologies were asm.js from Mozilla and Google Native Client,[21][22] and the initial implementation was based on the feature set of asm.js.[23][note 1]
In March 2017, the design of the minimum viable product (MVP) was declared to be finished and the preview phase ended.[25] 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.[26][27][28][29]
In June 2019, Chrome 75 was released with WebAssembly threads enabled by default.[30]
Since April 2022,[update] WebAssembly 2.0 has been in draft status,[31][32] which added many SIMD-related instructions and a new v128 datatype, with the ability for functions to return multiple values, and mass memory initialize/copy.
Implementations
[edit]While WebAssembly was initially designed to permit near-native code execution speed in the web browser, it has been considered valuable outside of such, in more generalized contexts.[33][34] Since WebAssembly's runtime environments (RE) are low-level virtual stack machines (akin to JVM or Flash VM) that may be embedded into host applications, some implementations create standalone runtime environments like Wasmtime and Wasmer .[9][10] WebAssembly runtime environments are embedded in application servers to host "server-side" WebAssembly applications and in other applications to support plug-in-based software extension architectures, e.g., "WebAssembly for Proxies" (proxy-wasm) which specifies a WebAssembly-based ABI for extending proxy servers.[35][36]
Web browsers
[edit]In November 2017, Mozilla declared support "in all major browsers",[37] after WebAssembly was enabled by default in Edge 16.[38] This support also includes mobile web browsers for iOS and Android. As of March 2024,[update] 99% of tracked web browsers support WebAssembly (version 1.0),[39] more than for its predecessor asm.js.[40] For some extensions, from the 2.0 draft standard, support may be lower, but still more than 90% of web browsers may already support, e.g. the reference types extension.[41]
Compilers
[edit]WebAssembly implementations usually use either ahead-of-time (AOT) or just-in-time (JIT) compilation, but may also use an interpreter. While the first implementations have landed in web browsers, there are also non-browser implementations for general-purpose use, including Wasmer,[10] Wasmtime[42] or WAMR,[16] wasm3, WAVM, and many others.[43]
Because WebAssembly executables are precompiled, it is possible to use a variety of programming languages to make them.[44] This is achieved either through direct compilation to Wasm, or through an implementation of their corresponding virtual machines in Wasm. Some 40 programming languages are reported to support Wasm as a compilation target.[45]
Emscripten compiles C and C++ to Wasm[25] using Clang as a frontend, replacing LLVM as backend and using Binaryen as an optimizer.[46] The Emscripten SDK can compile any LLVM-supported languages (such as C, C++ or Rust, among others) source code into a binary file which runs in the same sandbox as JavaScript code.[note 2] Emscripten provides bindings for several commonly used environment interfaces like WebGL.
As of version 8, a standalone Clang can compile C and C++ to Wasm.[51] Its initial aim was to support compilation from C and C++,[52] though support for other source languages such as Rust, .NET languages[53][54][45] and AssemblyScript[55] (TypeScript-like) is also emerging.
After the MVP release, WebAssembly added support for multithreading and garbage collection (WasmGC, and web browsers including Safari have added support for it),[56] which allowed more efficient compilation for garbage-collecting programming languages like C# (supported via Blazor), F# (supported via Bolero[57] with help of Blazor) and Python.[58]
A number of other languages have some support, including Python,[59] Julia,[60][61][62] Ruby[63] and Ring.[64][65]
A number of systems can compile Java and other JVM languages to JavaScript and WebAssembly. These include CheerpJ,[66] JWebAssembly[67] and TeaVM.[68] Kotlin supports WebAssembly directly.[69][70]
Limitations
[edit]Web browsers do not permit WebAssembly code to directly manipulate the Document Object Model. Wasm code must defer to JavaScript for this.[note 3]
In an October 2023 survey of developers, less than half of the 303 participants were satisfied with the state of WebAssembly. A large majority cited the need for improvement in four areas: WASI, debugging support, integration with JavaScript and browser APIs, and build tooling.[73]
For memory-intensive allocations in WebAssembly, there are "grave limitations that make many applications infeasible to be reliably deployed on mobile browsers [..] Currently allocating more than ~300MB of memory is not reliable on Chrome on Android without resorting to Chrome-specific workarounds, nor in Safari on iOS."[74]
All major browsers allow WebAssembly if Content-Security-Policy is not specified, or if "unsafe-eval" is used, but behave differently otherwise.[75] Chrome requires "unsafe-eval",[76][77] though a worker thread can be a workaround.[77]
Security considerations
[edit]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.[78][79][80] However, in order to explore these future language extensions, Google Chrome added experimental support for the WebAssembly thread proposal in October 2018.[81]
WebAssembly has been criticized for allowing greater ease of hiding the evidence for malware writers, scammers and phishing attackers; WebAssembly is present on the user's machine only in its compiled form, which "[makes malware] detection difficult".[82] Speed and the easy ability to conceal in WebAssembly have led to its use in hidden crypto mining within the website visitor's device.[82][83][78] Coinhive, a now defunct service facilitating cryptocurrency mining in website visitors' browsers, claims their "miner uses WebAssembly and runs with about 65% of the performance of a native Miner."[78] A June 2019 study from the Technische Universität Braunschweig analyzed the usage of WebAssembly in the Alexa top 1 million websites and found the prevalent use was for malicious crypto mining, and that malware accounted for more than half of the WebAssembly-using websites studied.[84][85] An April 2021 study from Universität Stuttgart found that since then crypto mining has been marginalized, falling to below 1% of all WebAssembly modules gathered from a wide range of sources, also including the Alexa top 1 million websites.[86]
As WebAssembly supports only structured control flow, it is amenable toward security verification techniques including symbolic execution.[87]
Performance
[edit]Benchmark results vary between implementations and between themselves. Performance was benchmarked early to be around 91% (i.e., 10% slower) for running code, not including load/instantiation time[88] or more recently between 100% and 33% of native rates,[89] and 120% of JavaScript (i.e. 20% faster).[90][note 4] However, a 2023 paper benchmarking the purported IoT energy-saving improvements using WebAsm compared to native C, Rust, Go, and JavaScript found no conclusive results for choosing WebAsm.[92]
A 2021 study suggested that WebAssembly, in the versions they tested at that time, was well faster than JavaScript in certain cases and browsers only, such as running a complex function on a small file, e.g. processing a graphics file, but that JavaScript had some optimizations available, e.g. JIT, that WebAssembly did not.[93]
Benchmarking has revealed several other pain-points for WebAssembly, such as poor performance because of no direct access to the DOM,[note 5] which are being addressed or may be addressed in the future.[95]
WASI
[edit]WebAssembly System Interface (WASI) is a simple interface (ABI and API) designed by Mozilla intended to be portable to any platform.[96] It provides POSIX-like features like file I/O constrained by capability-based security.[97][98] There are additional proposed ABI/APIs.[99][100]
WASI is influenced by CloudABI and Capsicum.[according to whom?]
Solomon Hykes , a co-founder of Docker, wrote in 2019, "If WASM+WASI existed in 2008, we wouldn't have needed to create Docker. That's how important it is. WebAssembly on the server is the future of computing."[101]
Specification
[edit]Host environment
[edit]The general standard provides core specifications for the JavaScript API and details on embedding.[5]
Virtual machine
[edit]Wasm code (binary code, i.e. bytecode) is intended to be run on a portable virtual stack machine (VM).[102] The VM is designed to be faster to parse and execute than JavaScript and to have compact code representation.[52] Any external functionality (like syscalls) that may be expected by Wasm binary code is not stipulated by the standard. It rather provides a way to deliver interfacing via modules by the host environment that the VM runs in.[103][9]
Wasm program
[edit]A Wasm program is designed as a separate module containing collections of various Wasm-defined values and program type definitions. These are provided in either binary or textual format (see below) that have a common structure.[104] Such a module may provide a start function that is executed upon instantiation of a wasm binary.
Instruction set
[edit]The core standard for the binary format of a Wasm program defines an instruction set architecture (ISA) consisting of specific binary encodings of types of operations which are executed by the VM (without specifying how exactly they must be executed).[105] The list of instructions includes standard memory load/store instructions, numeric, parametric, control of flow instruction types and Wasm-specific variable instructions.[106]
The number of opcodes used in the original standard (MVP) was a bit fewer than 200 of the 256 possible opcodes. Subsequent versions of WebAssembly pushed the number of opcodes a bit over 200. The WebAssembly SIMD proposal (for parallel processing) introduces an alternate opcode prefix (0xfd) for 128-bit SIMD. The concatenation of the SIMD prefix, plus an opcode that is valid after the SIMD prefix, forms a SIMD opcode. The SIMD opcodes bring an additional 236 instructions for the "minimum viable product" (MVP) SIMD capability (for a total of around 436 instructions).[107][108] Those instructions, the "finalized opcodes"[109] are enabled by default across Google's V8 (in Google Chrome), the SpiderMonkey engine in Mozilla Firefox, and the JavaScriptCore engine in Apple's Safari[110] and there are also some additional proposal for instructions for later "post SIMD MVP", and there's also a separate "relaxed-simd" proposal on the table.[111]
These SIMD opcodes are also portable and translate to native instruction sets like x64 and ARM. In contrast, neither Java's JVM nor CIL support SIMD, at their opcode level, i.e. in the standard; both do have some parallel APIs which provide SIMD speedup. There is an extension for Java adding intrinsics for x64 SIMD,[112] that isn't portable, i.e. not usable on ARM or smartphones. Smartphones can support SIMD by calling assembly code with SIMD, and C# has similar support.
Code representation
[edit]In March 2017, the WebAssembly Community Group reached consensus on the initial (MVP) binary format, JavaScript API, and reference interpreter.[113] It defines a WebAssembly binary format (.wasm
), which is not designed to be used by humans, as well as a human-readable WebAssembly text format (.wat
) that resembles a cross between S-expressions and traditional assembly languages.
The table below shows an example of a factorial function written in C and its corresponding WebAssembly code after compilation, shown both in .wat text format (a human-readable textual representation of WebAssembly) and in .wasm binary format (the raw bytecode, expressed below in hexadecimal), that is executed by a Web browser or run-time environment that supports WebAssembly.
C source code | WebAssembly .wat text format | WebAssembly .wasm binary format |
---|---|---|
int factorial(int n) {
if (n == 0)
return 1;
else
return n * factorial(n-1);
}
|
(func (param i64) (result i64)
local.get 0
i64.eqz
if (result i64)
i64.const 1
else
local.get 0
local.get 0
i64.const 1
i64.sub
call 0
i64.mul
end)
|
00 61 73 6D 01 00 00 00
01 06 01 60 01 7E 01 7E
03 02 01 00
0A 17 01
15 00
20 00
50
04 7E
42 01
05
20 00
20 00
42 01
7D
10 00
7E
0B
0B
|
All integer constants are encoded using a space-efficient, variable-length LEB128 encoding.[114]
The WebAssembly text format is more canonically written in a folded format using S-expressions. For instructions and expressions, this format is purely syntactic sugar and has no behavioral differences with the linear format.[115] Through wasm2wat
, the code above decompiles to:
(module
(type $t0 (func (param i64) (result i64)))
(func $f0 (type $t0) (param $p0 i64) (result i64)
(if $I0 (result i64) ;; $I0 is an unused label name
(i64.eqz
(local.get $p0)) ;; the name $p0 is the same as 0 here
(then
(i64.const 1))
(else
(i64.mul
(local.get $p0)
(call $f0 ;; the name $f0 is the same as 0 here
(i64.sub
(local.get $p0)
(i64.const 1))))))))
A module is implicitly generated by the compiler. The function is referenced by an entry of the type table in the binary, hence a type section and the type
emitted by the decompiler.[116] The compiler and decompiler can be accessed online.[117]
See also
[edit]- Architecture Neutral Distribution Format (ANDF)
- UNCOL
- Java bytecode
- Common Language Runtime
- LLVM
- Compilation
- Software portability
Notes
[edit]- ^ The asm.js file already provides near-native code execution speeds: "Even discarding the one score where asm.js did better, it executes at around 70% of the speed (i.e. slower) of native C++ code.[24] and can be considered a viable alternative for browsers that do not support WebAssembly or have it disabled for security reasons.
- ^ According to official documentation, the Emscripten SDK may be used to create
.wasm
files which then may be executed in a web browser.[47][48][49] Even though Emscripten can consume various languages when using Clang, some problems may arise.[50] - ^ For Rust/Wasm development, third-party libraries can provide some of the necessary JavaScript I/O.[71][72]
- ^ A personal web page of 2024 reported a benchmark of a simple game application on a mobile phone found between 110% and 190% (i.e. faster) of native rates depending on the browser.[91]
- ^ "WebAssembly provides no access to the surrounding environment other than via the JavaScript API described in the JS API specification."[94]
References
[edit]- ^ "WebAssembly/design/Semantics.md". GitHub. Retrieved 23 February 2021.
WebAssembly code can be considered a structured stack machine; a machine where most computations use a stack of values, but control flow is expressed in structured constructs such as blocks, ifs, and loops. In practice, implementations need not maintain an actual value stack, nor actual data structures for control; they need only behave as if they did so.
- ^ Mozilla. "Understanding WebAssembly text format". MDN Web Docs. Retrieved 9 December 2019.
- ^ "Introduction — WebAssembly 1.0". webassembly.github.io. Retrieved 18 June 2019.
WebAssembly is an open standard...
- ^ "Introduction — WebAssembly 1.0". webassembly.github.io. Retrieved 18 June 2019.
WebAssembly is a ... code format
- ^ a b "Conventions — WebAssembly 1.0". webassembly.github.io. Retrieved 17 May 2019.
WebAssembly is a programming language that has multiple concrete representations (its binary format and the text format). Both map to a common structure.
- ^ "Introduction — WebAssembly 1.0". webassembly.github.io. Retrieved 18 June 2019.
... this specification is complemented by additional documents defining interfaces to specific embedding environments such as the Web. These will each define a WebAssembly application programming interface (API) suitable for a given environment.
- ^ "Introduction — WebAssembly 1.1". webassembly.github.io. Retrieved 19 February 2021.
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.
- ^ Haas, Andreas; Rossberg, Andreas; Schuff, Derek L.; Titzer, Ben L.; Holman, Michael; Gohman, Dan; Wagner, Luke; Zakai, Alon; Bastien, JF (14 June 2017). "Bringing the Web Up to Speed with WebAssembly". SIGPLAN Notices. 52 (6): 185–200. doi:10.1145/3140587.3062363. ISSN 0362-1340.
While the Web is the primary motivation for WebAssembly, nothing in its design depends on the Web or a JavaScript environment. It is an open standard specifically designed for embedding in multiple contexts, and we expect that stand-alone implementations will become available in the future.
- ^ a b c "Outside the web: standalone WebAssembly binaries using Emscripten · V8". v8.dev. Retrieved 28 July 2020.
- ^ a b c "Wasmer - The Universal WebAssembly Runtime". wasmer.io. Retrieved 19 February 2021.
Compile everything to WebAssembly. Run it on any OS or embed it into other languages.
- ^ World Wide Web Consortium. "WebAssembly Core Specification". World Wide Web Consortium (W3). Retrieved 9 December 2019.
- ^ Couriol, Bruno. "WebAssembly 1.0 Becomes a W3C Recommendation and the Fourth Language to Run Natively in Browsers". infoq.com. Retrieved 9 December 2019.
- ^ "WebAssembly Specification — WebAssembly 1.1". webassembly.github.io. Retrieved 22 March 2021.
- ^ "Programming Languages Software Award". www.sigplan.org.
- ^ Bright, Peter (18 June 2015). "The Web is getting its bytecode: WebAssembly". Ars Technica. Condé Nast.
- ^ a b "New Bytecode Alliance Brings the Security, Ubiquity, and Interoperability of the Web to the World of Pervasive Computing". Mozilla. 12 November 2019. Retrieved 27 May 2019.
- ^ "Launch bug". GitHub / WebAssembly / design. 11 June 2015.
- ^ Wagner, Luke (14 March 2016). "A WebAssembly Milestone: Experimental Support in Multiple Browsers". Mozilla Hacks.
- ^ Thompson, Seth (15 March 2016). "Experimental support for WebAssembly in V8". V8 Blog.
- ^ Zhu, Limin (15 March 2016). "Previewing WebAssembly experiments in Microsoft Edge". Microsoft Edge dev blog.
- ^ 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.
- ^ Avram, Abel (31 May 2017). "Google Is to Remove Support for PNaCl". InfoQ. Retrieved 22 December 2017.
- ^ "WebAssembly: a binary format for the web". ②ality – JavaScript and more. 18 June 2015.
- ^ "Staring at the Sun: Dalvik vs. ASM.js vs. Native". blog.mozilla.org. August 2013. Retrieved 7 December 2019.
- ^ a b Krill, Paul (6 March 2017). "WebAssembly is now ready for browsers to use". InfoWorld. Retrieved 23 December 2017.
- ^ "WebAssembly First Public Working Drafts". W3C. 15 February 2018. Retrieved 20 April 2018.
- ^ "WebAssembly Core Specification". W3C. 15 February 2018. Retrieved 20 April 2018.
- ^ "WebAssembly JavaScript Interface". W3C. 15 February 2018. Retrieved 20 April 2018.
- ^ "WebAssembly Web API". W3C. 15 February 2018. Retrieved 20 April 2018.
- ^ "WebAssembly Worker Based Threads - Chrome Platform Status". chromestatus.com. Retrieved 19 February 2022.
- ^ "WebAssembly Specification — WebAssembly 2.0 (Draft 2022-09-01)". webassembly.github.io. Retrieved 9 September 2022.
- ^ "WebAssembly 2.0 First Public Working Drafts | W3C News". 19 April 2022. Retrieved 9 September 2022.
- ^ "Non-Web Embeddings". WebAssembly. Retrieved 15 May 2019.
- ^ "Non-Web Embeddings". GitHub / WebAssembly. Retrieved 15 May 2019.
- ^ Freese, Danny (October 3, 2023). "Proxy-Wasm: It's WebAssembly for Proxies". Blog. Kong. Retrieved 2024-05-06.
- ^ "proxy-wasm/spec: WebAssembly for Proxies (ABI specification)". GitHub. Retrieved 6 May 2024.
- ^ "WebAssembly support now shipping in all major browsers". The Mozilla Blog. Retrieved 21 November 2017.
- ^ "Introducing new JavaScript optimizations, WebAssembly, SharedArrayBuffer, and Atomics in EdgeHTML 16". Microsoft Edge Dev Blog. 31 October 2017. Retrieved 21 November 2017.
- ^ "WebAssembly | Can I use... Support tables for HTML5, CSS3, etc". canIuse.com. Retrieved 1 March 2024.
- ^ "asm.js | Can I use... Support tables for HTML5, CSS3, etc". caniuse.com. Retrieved 29 September 2024.
- ^ "WebAssembly Reference Types | Can I use... Support tables for HTML5, CSS3, etc". caniuse.com. Retrieved 3 March 2024.
- ^ "Wasmtime — a small and efficient runtime for WebAssembly & WASI". wasmtime.dev. Retrieved 18 December 2020.
- ^ "Roadmap". Retrieved 7 December 2021.
- ^ Ball, Kevin (26 June 2018). "How WebAssembly is Accelerating the Future of Web Development". Archived from the original on 12 February 2019. Retrieved 22 October 2018.
- ^ a b "Awesome WebAssembly Languages". GitHub. 26 June 2018. Retrieved 15 February 2022.
- ^ Zakai, Alon [@kripken] (21 October 2019). "Emscripten has switched to the upstream LLVM wasm backend by default! / Details:https://groups.google.com/forum/#!topic/emscripten-discuss/NpxVAOirSl4" (Tweet). Retrieved 22 October 2019 – via Twitter.
- ^ "Developer's Guide - WebAssembly". webassembly.org. Retrieved 10 June 2019.
- ^ "Compiling a New C/C++ Module to WebAssembly". MDN Web Docs. Retrieved 10 June 2019.
- ^ "Building to WebAssembly — Emscripten 1.38.33 documentation". emscripten.org. Retrieved 10 June 2019.
- ^ "Emscripting a C library to Wasm | Web". Google Developers. Retrieved 10 June 2019.
- ^ "LLVM 8.0.0 Release Notes — LLVM 8 documentation". releases.llvm.org. Retrieved 22 October 2019.
- ^ a b "WebAssembly High-Level Goals". GitHub / WebAssembly / design. 11 December 2015.
- ^ Krill, Paul (29 November 2017). "Direct WebAssembly compilation comes to Rust language". InfoWorld. Retrieved 24 December 2017.
- ^ "Frequently asked questions (FAQ) about Blazor". blazor.net. Retrieved 18 June 2018.
- ^ "AssemblyScript/assemblyscript". The AssemblyScript Project. 9 September 2020. Retrieved 9 September 2020.
- ^ "WebAssembly Garbage Collection (WasmGC) now enabled by default in Chrome | Blog". Chrome for Developers. Retrieved 11 December 2023.
- ^ "Bolero: F# in WebAssembly". fsbolero.io. Retrieved 25 July 2019.
- ^ "A new way to bring garbage collected programming languages efficiently to WebAssembly · V8". v8.dev. Retrieved 11 December 2023.
- ^ "Pyodide: Bringing the scientific Python stack to the browser – Mozilla Hacks - the Web developer blog". Mozilla Hacks – the Web developer blog. Retrieved 9 September 2020.
- ^ "Julia in the Browser". nextjournal.com. Retrieved 9 April 2019.
- ^ "WebAssembly platform by tshort · Pull Request #2 · JuliaPackaging/Yggdrasil". GitHub. Retrieved 9 April 2019.
- ^ Fischer, Keno (22 July 2019). "GitHub - Keno/julia-wasm: Running julia on wasm". GitHub. Retrieved 25 July 2019.
- ^ "MRuby in Your Browser". ruby.dj. Retrieved 25 July 2019.
- ^ Paul Krill (24 August 2020). "Ring language upgrade focuses on WebAssembly". InfoWorld.
- ^ "Ring in web browser". Retrieved 17 August 2024.
- ^ "Java to WebAssembly Compiler - CheerpJ". Retrieved 27 April 2023.
- ^ "JWebAssembly". 27 April 2023 – via GitHub.
- ^ "TeaVM — Overview". www.teavm.org. Retrieved 27 April 2023.
- ^ "Bringing Kotlin to the Web". Retrieved 11 December 2023.
- ^ Deleuze, Sébastien (13 February 2023). "The huge potential of Kotlin/Wasm". seb.deleuze.fr. Retrieved 11 December 2023.
- ^ "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.
- ^ "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.
- ^ "The State of WebAssembly 2023". Scott Logic. 18 October 2023. Retrieved 14 March 2024.
- ^ "Wasm needs a better memory management story · Issue #1397 · WebAssembly/design". GitHub. Retrieved 15 February 2021.
- ^ "WebAssembly/content-security-policy". GitHub. Retrieved 17 February 2021.
- ^ "948834 - chromium - An open-source project to help move the web forward. - Monorail". bugs.chromium.org. Retrieved 17 February 2021.
- ^ a b "No way to use WebAssembly on Chrome without 'unsafe-eval' · Issue #7 · WebAssembly/content-security-policy". GitHub. Retrieved 17 February 2021.
- ^ a b c Neumann, Robert; Toro, Abel (19 April 2018). "In-browser mining: Coinhive and WebAssembly". Forcepoint. Retrieved 8 June 2019.
- ^ Cimpanu, Catalin (24 June 2018). "Changes in WebAssembly Could Render Meltdown and Spectre Browser Patches Useless". Bleeping Computer. Retrieved 8 June 2019.
- ^ Sanders, James (25 June 2018). "How opaque WebAssembly code could increase the risk of Spectre attacks online". Tech Republic. Retrieved 9 June 2019.
- ^ R, Bhagyashree (30 October 2018). "Google Chrome 70 now supports WebAssembly threads to build multi-threaded web applications". Packt Pub. Retrieved 9 June 2019.
- ^ a b Lonkar, Aishwarya; Chandrayan, Siddhesh (October 2018). "The dark side of WebAssembly". Virus Bulletin. Retrieved 8 June 2019.
- ^ Segura, Jérôme (29 November 2017). "Persistent drive-by cryptomining coming to a browser near you". Malwarebytes. Retrieved 8 June 2019.
- ^ "Recent Study Estimates That 50% of Websites Using WebAssembly Apply It for Malicious Purposes". InfoQ. Retrieved 3 November 2019.
- ^ Musch, Marius; Wressnegger, Christian; Johns, Martin; Rieck, Konrad (June 2019). "New Kid on the Web: A Study on the Prevalence of WebAssembly in the Wild". Detection of Intrusions and Malware, and Vulnerability Assessment (PDF). Lecture Notes in Computer Science. Vol. 11543. Detection of Intrusions and Malware, and Vulnerability Assessment. pp. 23–42. doi:10.1007/978-3-030-22038-9_2. ISBN 978-3-030-22037-2. S2CID 184482682. Archived from the original (PDF) on 26 July 2022. Retrieved 15 February 2022. Slides (PDF) Archived 3 November 2019 at the Wayback Machine
- ^ Aaron Hilbig, Daniel Lehmann, and Michael Pradel (April 2021). "An Empirical Study of Real-World WebAssembly Binaries: Security, Languages, Use Cases." (Archived April 2021) https://software-lab.org/publications/www2021.pdf
- ^ Watt, Conrad (8 January 2018). "Mechanising and verifying the WebAssembly specification". Proceedings of the 7th ACM SIGPLAN International Conference on Certified Programs and Proofs. CPP 2018. Los Angeles CA USA: ACM. pp. 53–65. doi:10.1145/3167082. ISBN 978-1-4503-5586-5. S2CID 9401691.
- ^ Arjun, Jangda, Abhinav Powers, Bobby Berger, Emery Guha (25 January 2019). Not So Fast: Analyzing the Performance of WebAssembly vs. Native Code. OCLC 1106328738.
{{cite book}}
: CS1 maint: multiple names: authors list (link) - ^ Denis, Frank. "Performance of WebAssembly runtimes in 2023". 00f.net. Retrieved 6 December 2024.
- ^ De Macedo, Joao; Abreu, Rui; Pereira, Rui; Saraiva, Joao (June 2022). "WebAssembly versus JavaScript: Energy and Runtime Performance". 2022 International Conference on ICT for Sustainability (ICT4S). pp. 24–34. doi:10.1109/ICT4S55073.2022.00014. hdl:1822/90291. ISBN 978-1-6654-8286-8.
- ^ Turner, Aaron. "WebAssembly Is Fast: A Real-World Benchmark of WebAssembly vs. ES6".
- ^ Wagner, Linus; Mayer, Maximilian; Marino, Andrea; Soldani Nezhad, Alireza; Zwaan, Hugo; Malavolta, Ivano (14 June 2023). "On the Energy Consumption and Performance of WebAssembly Binaries across Programming Languages and Runtimes in IoT". Proceedings of the 27th International Conference on Evaluation and Assessment in Software Engineering: 72–82. doi:10.1145/3593434.3593454. ISBN 979-8-4007-0044-6.
- ^ Yan, Yutian; Tu, Tengfei; Zhao, Lijian; Zhou, Yuchen; Wang, Weihang (2 November 2021). "Understanding the performance of webassembly applications". Proceedings of the 21st ACM Internet Measurement Conference. pp. 533–549. doi:10.1145/3487552.3487827. ISBN 978-1-4503-9129-0.
- ^ "WebAssembly Web API". webassembly.github.io.
- ^ Kambale, Enoch. "WebAssembly in 2024: Promises, Challenges, and the Road Ahead". blog.enkambale.com. Retrieved 6 December 2024.
- ^ "WebAssembly System Interface Repo". GitHub / WebAssembly. 10 February 2020.
- ^ "Additional background on Capabilities". GitHub. bytecodealliance. 4 March 2022.
- ^ "Standardizing WASI: A system interface to run WebAssembly outside the web – Mozilla Hacks - the Web developer blog". Mozilla Hacks – the Web developer blog.
- ^ "reference-sysroot Repo". GitHub / WebAssembly. 12 January 2020.
- ^ "wasm-c-api Repo". GitHub / WebAssembly. 3 February 2020.
- ^ Hykes, Solomon (27 March 2019). "Solomon Hykes on X". Twitter. Retrieved 29 September 2024.
- ^ "Design Rationale". GitHub / WebAssembly / design. 1 October 2016.
- ^ "Portability - WebAssembly". webassembly.org. Retrieved 28 July 2020.
- ^ "Conventions — WebAssembly 1.0". webassembly.github.io. Retrieved 12 November 2019.
- ^ "Introduction — WebAssembly 1.0". webassembly.github.io. Retrieved 17 May 2019.
- ^ "Instructions — WebAssembly 1.0". webassembly.github.io. Retrieved 12 November 2019.
- ^ Lively, Thomas (19 February 2021) [Pull Request opened on 2021-02-05]. "Final opcodes by tlively · Pull Request #452 · WebAssembly/simd · GitHub". Bytecode Alliance. Retrieved 12 May 2021 – via GitHub.
- ^ Delendik, Yury (19 February 2021) [SIMD changes committed on 2021-02-19]. "File wasm-tools/expr.rs at b5c3d98e40590512a3b12470ef358d5c7b983b15 · bytecodealliance/wasm-tools · GitHub". Bytecode Alliance. Retrieved 12 May 2021 – via GitHub.
- ^ "Update interpreter and text with finalized opcodes by ngzhian · Pull Request #486 · WebAssembly/simd". GitHub. Retrieved 14 May 2021.
- ^ "WebAssembly/simd". GitHub. Retrieved 14 May 2021.
- ^ WebAssembly/relaxed-simd, WebAssembly, 3 May 2021, retrieved 14 May 2021
- ^ "How we made the JVM 40x faster". astojanov.github.io. Retrieved 17 February 2021.
- ^ "Roadmap". WebAssembly. March 2017.
- ^ WebAssembly Community Group (January 2020). "WebAssembly Specification Release 1.0". Retrieved 13 January 2020.
- ^ "Folded instructions". GitHub. / WebAssembly / spec
- ^ "Modules (Binary)". WebAssembly 1.0.
- ^ "WebAssembly Binary Toolkit (wabt) demos". webassembly.github.io.
This article incorporates text from a free content work. Licensed under Apache License 2.0 (license statement/permission). Text taken from Text Format, jfbastien; rossberg-chromium; kripken; titzer; s3ththompson; sunfishcode; lukewagner; flagxor; enricobacis; c3d; binji; andrewosh, GitHub. WebAssembly/design.
External links
[edit]- Official website
- W3C Community Group
- WebAssembly Specification
- WebAssembly Design Documents
- "WebAssembly", MDN Web Docs, 16 April 2024 – with info on browser compatibility and specifications (WebAssembly JavaScript API)