<s>
WebAssembly	O
(	O
sometimes	O
abbreviated	O
Wasm	O
)	O
defines	O
a	O
portable	B-Architecture
binary-code	O
format	O
and	O
a	O
corresponding	O
text	O
format	O
for	O
executable	B-Application
programs	I-Application
as	O
well	O
as	O
software	O
interfaces	O
for	O
facilitating	O
interactions	O
between	O
such	O
programs	O
and	O
their	O
host	O
environment	O
.	O
</s>
<s>
The	O
World	O
Wide	O
Web	O
Consortium	O
(	O
W3C	O
)	O
maintains	O
the	O
standard	O
with	O
contributions	O
from	O
Mozilla	B-Operating_System
,	O
Microsoft	O
,	O
Google	B-Application
,	O
Apple	O
,	O
Fastly	B-General_Concept
,	O
Intel	O
,	O
and	O
Red	O
Hat	O
.	O
</s>
<s>
WebAssembly	O
is	O
named	O
to	O
evoke	O
the	O
concept	O
of	O
assembly	B-Language
language	I-Language
,	O
a	O
term	O
which	O
dates	O
to	O
the	O
1950s	O
.	O
</s>
<s>
The	O
name	O
suggests	O
bringing	O
assembly-like	O
programming	O
to	O
the	O
Web	O
,	O
where	O
it	O
will	O
be	O
executed	O
client-side	B-Operating_System
by	O
the	O
website-user	O
'	O
s	O
computer	O
via	O
the	O
user	O
's	O
web	B-Application
browser	I-Application
.	O
</s>
<s>
To	O
accomplish	O
this	O
,	O
WebAssembly	O
must	O
be	O
much	O
more	O
hardware-independent	O
than	O
a	O
true	O
assembly	B-Language
language	I-Language
.	O
</s>
<s>
WebAssembly	O
was	O
first	O
announced	O
in	O
2015	O
,	O
and	O
the	O
first	O
demonstration	O
was	O
executing	O
Unity	B-Application
's	O
Angry	O
Bots	O
in	O
Firefox	B-Application
,	O
Google	B-Application
Chrome	I-Application
,	O
and	O
Microsoft	B-Application
Edge	I-Application
.	O
</s>
<s>
The	O
precursor	O
technologies	O
were	O
asm.js	B-Language
from	O
Mozilla	B-Operating_System
and	O
Google	B-Application
Native	I-Application
Client	I-Application
,	O
and	O
the	O
initial	O
implementation	O
was	O
based	O
on	O
the	O
feature	O
set	O
of	O
asm.js	B-Language
.	O
</s>
<s>
The	O
asm.js	B-Language
technology	O
already	O
provides	O
near-native	O
code	O
execution	O
speeds	O
and	O
can	O
be	O
considered	O
a	O
viable	O
alternative	O
for	O
browsers	B-Application
that	O
do	O
n't	O
support	O
WebAssembly	O
or	O
have	O
it	O
disabled	O
for	O
security	O
reasons	O
.	O
</s>
<s>
In	O
late	O
September	O
2017	O
,	O
Safari	B-Application
11	I-Application
was	O
released	O
with	O
support	O
.	O
</s>
<s>
In	O
February	O
2018	O
,	O
the	O
WebAssembly	O
Working	O
Group	O
published	O
three	O
public	O
working	O
drafts	O
for	O
the	O
Core	O
Specification	O
,	O
JavaScript	B-Language
Interface	O
,	O
and	O
Web	O
API	B-Application
.	O
</s>
<s>
In	O
June	O
2019	O
,	O
Chrome	B-Application
75	O
was	O
released	O
with	O
WebAssembly	O
threads	B-Operating_System
enabled	O
by	O
default	O
.	O
</s>
<s>
Since	O
April	O
2022	O
,	O
WebAssembly	O
2.0	O
is	O
in	O
draft	O
status	O
,	O
which	O
adds	O
many	O
SIMD-related	O
instructions	O
and	O
a	O
new	O
v128	O
datatype	O
,	O
the	O
ability	O
for	O
functions	O
to	O
return	O
multiple	O
values	O
,	O
and	O
mass	O
memory	O
initialize/copy	O
.	O
</s>
<s>
While	O
WebAssembly	O
was	O
initially	O
designed	O
to	O
enable	O
near-native	O
code	O
execution	O
speed	O
in	O
the	O
web	B-Application
browser	I-Application
,	O
it	O
has	O
been	O
considered	O
valuable	O
outside	O
of	O
such	O
,	O
in	O
more	O
generalized	O
contexts	O
.	O
</s>
<s>
Since	O
WebAssembly	O
's	O
runtime	O
environments	O
(	O
RE	O
)	O
are	O
low	O
level	O
virtual	B-Application
stack	I-Application
machines	I-Application
(	O
akin	O
to	O
JVM	B-Language
or	O
Flash	B-Operating_System
VM	I-Operating_System
)	O
that	O
can	O
be	O
embedded	O
into	O
host	O
applications	O
,	O
some	O
of	O
them	O
have	O
found	O
a	O
way	O
to	O
standalone	O
runtime	O
environments	O
like	O
Wasmtime	O
and	O
Wasmer	O
.	O
</s>
<s>
In	O
November	O
2017	O
,	O
Mozilla	B-Operating_System
declared	O
support	O
"	O
in	O
all	O
major	O
browsers	B-Application
"	O
,	O
after	O
WebAssembly	O
was	O
enabled	O
by	O
default	O
in	O
Edge	O
16	O
.	O
</s>
<s>
The	O
support	O
includes	O
mobile	O
web	B-Application
browsers	I-Application
for	O
iOS	O
and	O
Android	O
.	O
</s>
<s>
,	O
96%	O
of	O
installed	O
browsers	B-Application
support	O
WebAssembly	O
(	O
version	O
1.0	O
)	O
.	O
</s>
<s>
But	O
for	O
older	O
browsers	B-Application
,	O
Wasm	O
can	O
be	O
compiled	B-Language
into	O
asm.js	B-Language
by	O
a	O
JavaScript	B-Language
polyfill	B-Protocol
.	O
</s>
<s>
WebAssembly	O
implementations	O
usually	O
use	O
either	O
ahead-of-time	B-Application
(	O
AOT	B-Application
)	O
or	O
just-in-time	O
(	O
JIT	O
)	O
compilation	B-Language
,	O
but	O
may	O
also	O
use	O
an	O
interpreter	B-Application
.	O
</s>
<s>
While	O
the	O
first	O
implementations	O
have	O
landed	O
in	O
web	B-Application
browsers	I-Application
,	O
there	O
are	O
also	O
non-browser	O
implementations	O
for	O
general-purpose	O
use	O
,	O
including	O
Wasmer	O
,	O
Wasmtime	O
or	O
WAMR	O
,	O
wasm3	O
,	O
WAVM	O
,	O
and	O
many	O
others	O
.	O
</s>
<s>
Because	O
WebAssembly	O
executables	B-Application
are	O
precompiled	O
,	O
it	O
is	O
possible	O
to	O
use	O
a	O
variety	O
of	O
programming	O
languages	O
to	O
make	O
them	O
.	O
</s>
<s>
This	O
is	O
achieved	O
either	O
through	O
direct	O
compilation	B-Language
to	O
Wasm	O
,	O
or	O
through	O
implementation	O
of	O
the	O
corresponding	O
virtual	O
machines	O
in	O
Wasm	O
.	O
</s>
<s>
There	O
have	O
been	O
around	O
40	O
programming	O
languages	O
reported	O
to	O
support	O
Wasm	O
as	O
a	O
compilation	B-Language
target	O
.	O
</s>
<s>
Emscripten	B-Language
compiles	B-Language
C	B-Language
and	O
C++	B-Language
to	O
Wasm	O
using	O
the	O
Binaryen	O
and	O
LLVM	B-Application
as	O
backend	O
.	O
</s>
<s>
The	O
Emscripten	B-Language
SDK	I-Language
can	O
compile	B-Language
any	O
LLVM-supported	O
languages	O
(	O
such	O
as	O
C	B-Language
,	O
C++	B-Language
or	O
Rust	B-Application
,	O
among	O
others	O
)	O
source	O
code	O
into	O
a	O
binary	O
file	O
which	O
runs	O
in	O
the	O
same	O
sandbox	O
as	O
JavaScript	B-Language
code	O
.	O
</s>
<s>
Emscripten	B-Language
provides	O
bindings	O
for	O
several	O
commonly	O
used	O
environment	O
interfaces	O
like	O
WebGL	B-Library
.	O
</s>
<s>
As	O
of	O
version	O
8	O
,	O
a	O
standalone	O
Clang	B-Application
can	O
compile	B-Language
C	B-Language
and	O
C++	B-Language
to	O
Wasm	O
.	O
</s>
<s>
Its	O
initial	O
aim	O
is	O
to	O
support	O
compilation	B-Language
from	O
C	B-Language
and	O
C++	B-Language
,	O
though	O
support	O
for	O
other	O
source	O
languages	O
such	O
as	O
Rust	B-Application
,	O
.NET	B-Language
languages	I-Language
and	O
AssemblyScript	B-Application
(	O
TypeScript-like	O
)	O
is	O
also	O
emerging	O
.	O
</s>
<s>
After	O
the	O
MVP	O
release	O
,	O
there	O
are	O
plans	O
to	O
support	O
multithreading	B-Operating_System
and	O
garbage	B-General_Concept
collection	I-General_Concept
which	O
would	O
make	O
WebAssembly	O
a	O
compilation	B-Language
target	O
for	O
garbage-collected	O
programming	O
languages	O
like	O
C#	B-Application
(	O
supported	O
via	O
Blazor	B-Operating_System
)	O
,	O
F#	B-Operating_System
(	O
supported	O
via	O
Bolero	O
with	O
help	O
of	O
Blazor	B-Operating_System
)	O
,	O
Python	B-Language
,	O
and	O
even	O
JavaScript	B-Language
where	O
the	O
browser	B-Application
's	O
just-in-time	O
compilation	B-Language
speed	O
is	O
considered	O
too	O
slow	O
.	O
</s>
<s>
A	O
number	O
of	O
other	O
languages	O
have	O
some	O
support	O
including	O
Python	B-Language
,	O
Julia	B-Application
,	O
and	O
Ruby	B-Language
.	O
</s>
<s>
In	O
general	O
,	O
WebAssembly	O
does	O
not	O
allow	O
direct	O
interaction	O
with	O
the	B-General_Concept
DOM	I-General_Concept
.	O
</s>
<s>
All	O
interaction	O
must	O
flow	O
through	O
JavaScript	B-Language
interop	O
.	O
</s>
<s>
Absence	O
of	O
garbage	B-General_Concept
collection	I-General_Concept
(	O
although	O
there	O
are	O
plans	O
to	O
address	O
this	O
.	O
)	O
</s>
<s>
WebAssembly	O
is	O
supported	O
on	O
desktops	O
,	O
and	O
mobile	O
,	O
but	O
on	O
the	O
latter	O
,	O
in	O
practice	O
(	O
for	O
non-small	O
memory	O
allocations	O
,	O
such	O
as	O
with	O
Unity	B-Application
game	I-Application
engine	I-Application
)	O
there	O
are	O
"	O
grave	O
limitations	O
that	O
make	O
many	O
applications	O
infeasible	O
to	O
be	O
reliably	O
deployed	O
on	O
mobile	O
browsers	B-Application
 [ .. ] 	O
Currently	O
allocating	O
more	O
than	O
~	O
300MB	O
of	O
memory	O
is	O
not	O
reliable	O
on	O
Chrome	B-Application
on	O
Android	O
without	O
resorting	O
to	O
Chrome-specific	O
workarounds	O
,	O
nor	O
in	O
Safari	B-Application
on	O
iOS.	O
"	O
</s>
<s>
There	O
is	O
no	O
direct	O
Document	B-General_Concept
Object	I-General_Concept
Model	I-General_Concept
(	O
DOM	B-General_Concept
)	O
access	O
;	O
however	O
,	O
it	O
is	O
possible	O
to	O
create	O
proxy	O
functions	O
for	O
this	O
,	O
for	O
example	O
through	O
stdweb	O
or	O
web_sys	O
when	O
using	O
the	O
Rust	B-Application
language	I-Application
.	O
</s>
<s>
All	O
major	O
web	B-Application
browsers	I-Application
allow	O
WebAssembly	O
if	O
Content-Security-Policy	O
is	O
not	O
specified	O
,	O
or	O
if	O
"	O
unsafe-eval	O
"	O
is	O
used	O
,	O
but	O
otherwise	O
the	O
major	O
web	B-Application
browsers	I-Application
behave	O
differently	O
.	O
</s>
<s>
In	O
practice	O
WebAssembly	O
ca	O
n't	O
be	O
used	O
on	O
Chrome	B-Application
without	O
"	O
unsafe-eval	O
"	O
,	O
while	O
a	O
worker	O
thread	B-Operating_System
workaround	O
is	O
available	O
.	O
</s>
<s>
In	O
June	O
2018	O
,	O
a	O
security	O
researcher	O
presented	O
the	O
possibility	O
of	O
using	O
WebAssembly	O
to	O
circumvent	O
browser	B-Application
mitigations	O
for	O
Spectre	B-Error_Name
and	O
Meltdown	B-Architecture
security	O
vulnerabilities	O
once	O
support	O
for	O
threads	B-Operating_System
with	O
shared	O
memory	O
is	O
added	O
.	O
</s>
<s>
However	O
,	O
in	O
order	O
to	O
explore	O
these	O
future	O
language	O
extensions	O
,	O
Google	B-Application
Chrome	I-Application
added	O
experimental	O
support	O
for	O
the	O
WebAssembly	O
thread	B-Operating_System
proposal	O
in	O
October	O
2018	O
.	O
</s>
<s>
WebAssembly	O
has	O
been	O
criticized	O
for	O
allowing	O
greater	O
ease	O
of	O
hiding	O
the	O
evidence	O
for	O
malware	O
writers	O
,	O
scammers	O
and	O
phishing	O
attackers	O
;	O
WebAssembly	O
is	O
present	O
on	O
the	O
user	O
's	O
machine	O
only	O
in	O
its	O
compiled	B-Language
form	O
,	O
which	O
"	O
[	O
makes	O
malware ]	O
detection	O
difficult	O
"	O
.	O
</s>
<s>
Coinhive	O
,	O
a	O
now	O
defunct	O
service	O
facilitating	O
cryptocurrency	O
mining	O
in	O
website	O
visitors	O
 '	O
browsers	B-Application
,	O
claims	O
their	O
"	O
miner	O
uses	O
WebAssembly	O
and	O
runs	O
with	O
about	O
65%	O
of	O
the	O
performance	O
of	O
a	O
native	O
Miner.	O
"	O
</s>
<s>
The	O
ability	O
to	O
effectively	O
obfuscate	O
large	O
amounts	O
of	O
code	O
can	O
also	O
be	O
used	O
to	O
disable	O
ad	O
blocking	O
and	O
privacy	O
tools	O
that	O
prevent	O
web	B-Application
tracking	I-Application
like	O
Privacy	B-Operating_System
Badger	I-Operating_System
.	O
</s>
<s>
As	O
WebAssembly	O
supports	O
only	O
structured	B-Language
control	O
flow	O
,	O
it	O
is	O
amenable	O
toward	O
security	O
verification	O
techniques	O
including	O
symbolic	B-General_Concept
execution	I-General_Concept
.	O
</s>
<s>
Current	O
efforts	O
in	O
this	O
direction	O
include	O
the	O
Manticore	O
symbolic	B-General_Concept
execution	I-General_Concept
engine	O
.	O
</s>
<s>
WebAssembly	B-Application
System	I-Application
Interface	I-Application
(	O
WASI	O
)	O
is	O
a	O
simple	O
interface	O
(	O
ABI	B-Operating_System
and	O
API	B-Application
)	O
designed	O
by	O
Mozilla	B-Operating_System
intended	O
to	O
be	O
portable	B-Architecture
to	O
any	O
platform	O
.	O
</s>
<s>
There	O
are	O
also	O
a	O
few	O
other	O
proposed	O
ABI/APIs	O
.	O
</s>
<s>
Solomon	O
Hykes	O
,	O
a	O
co-founder	O
of	O
Docker	B-Language
,	O
wrote	O
in	O
2019	O
,	O
"	O
If	O
WASM+WASI	O
existed	O
in	O
2008	O
,	O
we	O
would	O
n't	O
have	O
needed	O
to	O
create	O
Docker	B-Language
.	O
</s>
<s>
Wasmer	O
,	O
out	O
in	O
version	O
1.0	O
,	O
provides	O
"	O
software	O
containerization	O
,	O
we	O
create	O
universal	O
binaries	O
that	O
work	O
anywhere	O
without	O
modification	O
,	O
including	O
operating	O
systems	O
like	O
Linux	O
,	O
macOS	O
,	O
Windows	O
,	O
and	O
web	B-Application
browsers	I-Application
.	O
</s>
<s>
The	O
general	O
standard	O
provides	O
core	O
specifications	O
for	O
JavaScript	B-Language
API	B-Application
and	O
details	O
on	O
embedding	O
.	O
</s>
<s>
bytecode	O
)	O
is	O
intended	O
to	O
be	O
run	O
on	O
a	O
portable	B-Architecture
virtual	O
stack	B-Application
machine	I-Application
(	O
VM	O
)	O
.	O
</s>
<s>
The	O
VM	O
is	O
designed	O
to	O
be	O
faster	O
to	O
parse	O
and	O
execute	O
than	O
JavaScript	B-Language
and	O
to	O
have	O
a	O
compact	O
code	O
representation	O
.	O
</s>
<s>
An	O
external	O
functionality	O
(	O
like	O
syscalls	B-Operating_System
)	O
that	O
may	O
be	O
expected	O
by	O
Wasm	O
binary	O
code	O
is	O
not	O
stipulated	O
by	O
the	O
standard	O
.	O
</s>
<s>
The	O
core	O
standard	O
for	O
the	O
binary	O
format	O
of	O
a	O
Wasm	O
program	O
defines	O
an	O
instruction	B-General_Concept
set	I-General_Concept
architecture	I-General_Concept
(	O
ISA	O
)	O
consisting	O
of	O
specific	O
binary	B-Language
encodings	I-Language
of	O
types	O
of	O
operations	O
which	O
are	O
executed	O
by	O
the	O
VM	O
(	O
without	O
specifying	O
how	O
exactly	O
they	O
must	O
be	O
executed	O
)	O
.	O
</s>
<s>
The	O
list	O
of	O
instructions	O
includes	O
standard	O
memory	O
load/store	B-General_Concept
instructions	I-General_Concept
,	O
numeric	O
,	O
parametric	O
,	O
control	O
of	O
flow	O
instruction	B-General_Concept
types	I-General_Concept
and	O
Wasm-specific	O
variable	O
instructions	O
.	O
</s>
<s>
The	O
number	O
of	O
opcodes	B-Language
used	O
in	O
the	O
original	O
standard	O
(	O
MVP	O
)	O
was	O
a	O
bit	O
fewer	O
than	O
200	O
of	O
the	O
256	O
possible	O
opcodes	B-Language
.	O
</s>
<s>
Subsequent	O
versions	O
of	O
WebAssembly	O
pushed	O
the	O
number	O
of	O
opcodes	B-Language
a	O
bit	O
over	O
200	O
.	O
</s>
<s>
The	O
WebAssembly	O
SIMD	B-Device
proposal	O
(	O
for	O
parallel	O
processing	O
)	O
introduces	O
an	O
alternate	O
opcode	B-Language
prefix	O
(	O
0xfd	O
)	O
for	O
128-bit	O
SIMD	B-Device
.	O
</s>
<s>
The	O
concatenation	O
of	O
the	O
SIMD	B-Device
prefix	O
,	O
plus	O
an	O
opcode	B-Language
that	O
is	O
valid	O
after	O
the	O
SIMD	B-Device
prefix	O
,	O
forms	O
a	O
SIMD	B-Device
opcode	B-Language
.	O
</s>
<s>
The	O
SIMD	B-Device
opcodes	B-Language
bring	O
an	O
additional	O
236	O
instructions	O
for	O
the	O
"	O
minimum	O
viable	O
product	O
"	O
(	O
MVP	O
)	O
SIMD	B-Device
capability	O
(	O
for	O
a	O
total	O
of	O
around	O
436	O
instructions	O
)	O
.	O
</s>
<s>
Those	O
instructions	O
,	O
the	O
"	O
finalized	O
opcodes	B-Language
"	O
are	O
implemented	O
in	O
Google	B-Application
's	I-Application
V8	O
(	O
in	O
Google	B-Application
Chrome	I-Application
)	O
and	O
in	O
the	O
corresponding	O
engine	O
in	O
Mozilla	B-Application
Firefox	I-Application
(	O
but	O
not	O
enabled	O
in	O
stable	O
versions	O
of	O
the	O
web	B-Application
browsers	I-Application
)	O
,	O
and	O
there	O
are	O
also	O
some	O
additional	O
proposal	O
for	O
instructions	O
for	O
later	O
"	O
post	O
SIMD	B-Device
MVP	O
"	O
,	O
and	O
there	O
's	O
also	O
a	O
separate	O
"	O
relaxed-simd	O
"	O
proposal	O
on	O
the	O
table	O
.	O
</s>
<s>
These	O
SIMD	B-Device
opcodes	B-Language
are	O
also	O
portable	B-Architecture
and	O
translate	O
to	O
native	O
instruction	B-General_Concept
sets	I-General_Concept
like	O
x64	O
and	O
ARM	O
.	O
</s>
<s>
In	O
contrast	O
,	O
neither	O
Java	O
's	O
JVM	B-Language
(	O
nor	O
CIL	B-Architecture
)	O
support	O
SIMD	B-Device
,	O
at	O
their	O
opcode	B-Language
level	O
,	O
i.e.	O
</s>
<s>
in	O
the	O
standard	O
;	O
both	O
do	O
have	O
some	O
parallel	O
APIs	B-Application
which	O
provide	O
SIMD	B-Device
speedup	O
.	O
</s>
<s>
There	O
is	O
an	O
extension	O
for	O
Java	O
adding	O
intrinsics	O
for	O
x64	O
SIMD	B-Device
,	O
that	O
is	O
n't	O
portable	B-Architecture
,	O
i.e.	O
</s>
<s>
Smartphones	O
can	O
support	O
SIMD	B-Device
by	O
calling	O
assembly	B-Language
code	I-Language
with	O
SIMD	B-Device
,	O
and	O
C#	B-Application
has	O
similar	O
support	O
.	O
</s>
<s>
In	O
March	O
2017	O
,	O
the	O
WebAssembly	O
Community	O
Group	O
reached	O
consensus	O
on	O
the	O
initial	O
(	O
MVP	O
)	O
binary	O
format	O
,	O
JavaScript	B-Language
API	B-Application
,	O
and	O
reference	O
interpreter	B-Application
.	O
</s>
<s>
It	O
defines	O
a	O
WebAssembly	O
binary	O
format	O
(	O
)	O
,	O
which	O
is	O
not	O
designed	O
to	O
be	O
used	O
by	O
humans	O
,	O
as	O
well	O
as	O
a	O
human-readable	O
WebAssembly	O
text	O
format	O
(	O
)	O
that	O
resembles	O
a	O
cross	O
between	O
S-expressions	B-Protocol
and	O
traditional	O
assembly	B-Language
languages	I-Language
.	O
</s>
<s>
The	O
table	O
below	O
shows	O
an	O
example	O
of	O
a	O
factorial	O
function	O
written	O
in	O
C	B-Language
and	O
its	O
corresponding	O
WebAssembly	O
code	O
after	O
compilation	B-Language
,	O
shown	O
both	O
in	O
text	O
format	O
(	O
a	O
human-readable	O
textual	O
representation	O
of	O
WebAssembly	O
)	O
and	O
in	O
binary	O
format	O
(	O
the	O
raw	O
bytecode	O
,	O
expressed	O
below	O
in	O
hexadecimal	O
)	O
,	O
that	O
is	O
executed	O
by	O
a	O
Web	B-Application
browser	I-Application
or	O
run-time	O
environment	O
that	O
supports	O
WebAssembly	O
.	O
</s>
<s>
All	O
integer	O
constants	O
are	O
encoded	O
using	O
a	O
space-efficient	O
,	O
variable-length	O
LEB128	B-Algorithm
encoding	O
.	O
</s>
<s>
The	O
WebAssembly	O
text	O
format	O
is	O
more	O
canonically	O
written	O
in	O
a	O
folded	O
format	O
using	O
S-expressions	B-Protocol
.	O
</s>
<s>
Note	O
that	O
a	O
module	O
is	O
implicitly	O
generated	O
by	O
the	O
compiler	B-Language
.	O
</s>
<s>
The	O
compiler	B-Language
and	O
decompiler	O
can	O
be	O
accessed	O
online	O
.	O
</s>
