@@ -87,9 +87,9 @@ \chapter{WebAssembly}
87
87
The language is defined as a virtual instruction set, encapsulating the
88
88
semantics of the program in a format that is independent of the underlying
89
89
system on which the program runs.
90
- WebAssembly supports two official formats: a readable text format and a
91
- more efficient binary format\cite {WasmSpec }.
92
- Both formats are based directly from the language's abstract syntax.
90
+ WebAssembly supports two official formats: a readable text format and a more
91
+ efficient binary format\cite {WasmSpec }; both formats are based directly from
92
+ the language's abstract syntax.
93
93
The binary format is a space-efficient mapping of syntax expressions
94
94
into a sequence of raw bytes, with each distinct sequence of bytes
95
95
representing exactly one possible combination of syntax elements
@@ -106,57 +106,36 @@ \chapter{WebAssembly}
106
106
stack of values and pushing the operation's result onto the stack afterward.
107
107
Strictly speaking this is not completely true, as the language's inclusion of
108
108
local variables allows circumvention of completely stack-based
109
- execution\cite {WasmNotStackMachine }.
110
- This has led to challenges for implementers of Lightbeam, an optimizing
111
- streaming WebAssembly compiler\cite {IntroducingLightbeam }.
112
-
109
+ execution\cite {WasmNotStackMachine }; this has led to challenges for
110
+ implementers of Lightbeam, an optimizing streaming WebAssembly
111
+ compiler\cite {IntroducingLightbeam }.
113
112
Memory operations are fully sandboxed by the WebAssembly execution environment.
114
113
WebAssembly memories are single lists of raw bytes\cite [p. 16]{WasmSpec }.
115
114
Each WebAssembly module can include a single memory vector, and any
116
115
computations the module performs that requires memory utilizes this list
117
116
of bytes, no direct access of the underlying system's physical or virtual
118
117
memory is permitted.
119
118
120
- WebAssembly programs are executed by virtual machines, which provide an
119
+ WebAssembly programs are executed by virtual machines, which provide an
121
120
abstraction layer between the program and the underlying system.
122
- These virtual machines are typically embedded within a host environment.
123
- The connection between the host environment (embedding environment) and the
124
- virtual machine executing the WebAssembly program is called an
125
- \textit {embedder }.
121
+ The connection between the host environment which runs the virtual machine
122
+ (embedding environment) and the virtual machine executing the WebAssembly
123
+ program is called an \textit {embedder }.
126
124
In order to interact with the host environment, WebAssembly embedders may
127
125
expose functionality via application programming interfaces (APIs): defined
128
126
functions that WebAssembly can use to interact with the environment.
129
127
With the Web as the primary embedding environment, Web embeddings provide a
130
128
defined JavaScript API that allows interaction between web pages.
131
129
132
- Instructions are grouped into several categories: numeric instructions which
133
- perform various mathematical operations on specific numeric value types,
134
- parametric instructions which can operate on any value type, variable
135
- instructions for manipulating local or global variables, memory instructions
136
- for manipulating the linear memory, and control instructions for manipulating
137
- the program's control flow.
138
- Notably for a lower level language, WebAssembly's control flow is fully
139
- structured: there is no rudimentary \texttt {goto }-like construct, the flow of
140
- the program is manipulated only by structured instructions such as blocks and
141
- loops, if statements, and branch instructions.
142
- In addition to the above \textit {basic instructions } that are available to
143
- programmers, the specification also defines several \textit {administrative
144
- instructions } which are used to express the reduction of various basic
145
- instructions.
146
- Administrative instructions cannot be called directly, but are internally used
147
- by the virtual machine to represent resulting intermediate states.
148
- As examples, the \texttt {trap } instruction represents the reduction of an
149
- erroneous state, and the \texttt {invoke } instruction represents the invocation
150
- of a function instance by its address in memory.
151
-
152
130
Embedding environments are free to expose any level of functionality to
153
- WebAssembly. This is enabled by the concept of \textit {host functions },
154
- functions provided by the environment that can be invoked by WebAssembly code .
131
+ WebAssembly, enabled by the concept of \textit {host functions } provided by the
132
+ environment that can be invoked by WebAssembly.
155
133
Host functions can receive and return values like regular functions, though
156
- they can also modify the store\cite [p. 78]{WasmSpec }.
134
+ they can also modify the store, the abstract model of the program's global
135
+ state\cite [p. 78]{WasmSpec }.
157
136
WebAssembly itself provides no guarantees about the determinism of host
158
- functions. As far as WebAssembly is concerned, such functions can be assumed to
159
- succeed or fail arbitrarily at the whims of the embedding environment.
137
+ functions---as far as WebAssembly is concerned, such functions can be assumed
138
+ to succeed or fail arbitrarily at the whims of the embedding environment.
160
139
If the function call succeeds, a compliant embedding environment is required to
161
140
correctly remove the expected number of arguments from the stack, and return
162
141
the declared number of values.
@@ -166,10 +145,30 @@ \chapter{WebAssembly}
166
145
Examples of host functions include functions for reading and writing system
167
146
files or performing network operations in a non-Web environment.
168
147
148
+ WebAssembly instructions are grouped into several categories: numeric
149
+ instructions which perform various mathematical operations on specific numeric
150
+ value types, parametric instructions which can operate on any value type,
151
+ variable instructions for manipulating local or global variables, memory
152
+ instructions for manipulating the linear memory, and control instructions for
153
+ manipulating the program's control flow.
154
+ Notable for a lower level language, WebAssembly's control flow is fully
155
+ structured: there is no rudimentary \texttt {goto }-like construct, the flow of
156
+ the program is manipulated only by structured instructions such as blocks and
157
+ loops, if statements, and branch instructions.
158
+ In addition to the \textit {basic instructions } that are available to
159
+ programmers, the specification also defines several \textit {administrative
160
+ instructions } which are used to express the reduction of various basic
161
+ instructions.
162
+ Administrative instructions cannot be called directly, but are internally used
163
+ by the virtual machine to represent resulting intermediate states.
164
+ As examples, the \texttt {trap } instruction represents the reduction of an
165
+ erroneous state, and the \texttt {invoke } instruction represents the invocation
166
+ of a function instance by its address in memory.
167
+
169
168
\section {Non-Web Embeddings }
170
169
171
- As its name implies, its primary focus is Web-based software; however it is not
172
- specific or tied to the Web.
170
+ As the name \textit { WebAssembly } implies, its primary focus is Web-based
171
+ software; though it is not solely tied to the Web.
173
172
Other non-Web environments execute WebAssembly for a variety of reasons: its
174
173
safe memory model, its high performance, and it being a universal,
175
174
encapsulated, and independent compile target.
@@ -186,7 +185,6 @@ \section{Non-Web Embeddings}
186
185
allowing optimal portability of systems-focused WebAssembly programs while
187
186
maintaining the security and sandboxing of the WebAssembly
188
187
platform\cite {StandardizingWasi }.
189
-
190
188
WASI's
191
189
\href {https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md#-fd_readdirfd-fd-buf-pointeru8-buf_len-size-cookie-dircookie---errno-size}{\texttt {fd\_ readdir }},
192
190
for example, is a host function that allows WebAssembly code to read the
@@ -211,47 +209,39 @@ \section{Past experiments}
211
209
software into their browsers that allowed them to work.
212
210
Because they operated only using browser plugins, they are unsupported on
213
211
popular mobile platforms such as Android and iOS.
212
+ WebAssembly, by contrast, is developed in the open as a web standard, the
213
+ direction of the project is not at the sole discretion of any one organization.
214
+ WebAssembly virtual machines are integrated directly into modern browsers,
215
+ requiring no additional action by the user to enable.
214
216
If a given applet requires a newer version of the JRE than is installed on the
215
217
system, or if no JRE installed at all, the user must download and install it.
216
218
The Java 8 Runtime Environment installer currently is between 60 and 80 MB,
217
219
depending on the platform.
218
220
Performing this installation requires administrative privileges, preventing
219
221
users on shared systems from running the applet if they are not able to
220
222
perform the installation.
221
- WebAssembly, by contrast, is developed in the open as a web standard, the
222
- direction of the project is not at the sole discretion of any one organization.
223
- WebAssembly virtual machines are integrated directly into modern browsers,
224
- requiring no additional action by the user to enable.
225
-
226
- While both Flash and Java Applets provided ways to interact with JavaScript and
227
- the web page, the primary way for a user to interact with both were via the
223
+ While WebAssembly requires its own execution environment like Flash and Java
224
+ Applets, on the Web this environment is intertwined heavily with existing
225
+ JavaScript engines: the three most popular web browsers, Apple's Safari,
226
+ Google's Chrome, and Mozilla's Firefox, each execute WebAssembly using their
227
+ previously-existing JavaScript
228
+ engines\cite {WebkitAssemblingWebAssembly ,V8 ,SpiderMonkeyDevBlog }.
229
+
230
+ Both Flash and Java Applets provided ways to interact with JavaScript and the
231
+ web page, but the primary way for a user to interact with both were via the
228
232
plugins' embedded objects within the page.
229
233
This disconnect between the web page and the application resulted in a jarring
230
234
disintegrated experience for users, and poor or nonexistent accessibility by
231
235
default for screen readers.
232
236
WebAssembly, by contrast, does \textit {not } have its own way of interacting
233
- with the user---all input and output is performed using the JavaScript bridge.
234
- While WebAssembly does require its own execution environment
235
- similarly to Flash and Java Applets, on the Web this environment is intertwined
236
- heavily with existing JavaScript engines.
237
- The three most popular web browsers, Apple's Safari, Google's Chrome, and
238
- Mozilla's Firefox, each execute WebAssembly using their previously-existing
239
- JavaScript engines\cite {WebkitAssemblingWebAssembly ,V8 ,SpiderMonkeyDevBlog }.
240
- All interactions require utilizing the web embedding's host functions, defined
241
- by the WebAssembly JavaScript Interface\cite {JSInterface } and Web-specific
242
- extensions provided by the Web API\cite {WebAPI }.
237
+ with the user---all interactions require utilizing the web embedding's host
238
+ functions, defined by the WebAssembly JavaScript Interface\cite {JSInterface }
239
+ and Web-specific extensions provided by the Web API\cite {WebAPI }.
243
240
While this may result in more work on the part of programmers, one must
244
241
perform all input and output by going through JavaScript, it results
245
242
in a fully integrated experience by the user: something that is \textit {part }
246
243
of the Web, not something that is simply stuck inside the webpage.
247
244
248
- While WebAssembly is a language in itself that one could write directly,
249
- it was designed from the beginning to be a standard compile target.
250
- While it is possible to compile other languages to be executable by the Java
251
- Virtual Machine and thus run in Java Applets, doing so is analogous to
252
- compiling other languages to JavaScript so they can be executed on the
253
- Web---not a first class way of writing software.
254
-
255
245
Finally, as previously mentioned, WebAssembly was designed with major goals of
256
246
high performance and security.
257
247
While Java applets and Flash applications can offer high performance in optimal
@@ -267,11 +257,11 @@ \section{Past experiments}
267
257
Steve Jobs, CEO of Apple and the primary inventor of the iPhone, listed many of
268
258
the above reasons for his refusal to provide support for Flash on iPhone
269
259
devices\cite {ThoughtsOnFlash }.
270
- This lack of support on the popular devices, along with
271
- the advancement of more powerful open and standardized Web platform
272
- features, resulted in Flash falling out of favor\cite {FlashKilledOff }.
273
- Flash was deprecated in 2017 by Adobe, with an end-of-life date of
274
- December 2020\cite {FlashFuture }.
260
+ This lack of support on popular mobile devices, along with the advancement of
261
+ more powerful open and standardized Web platform features, resulted in Flash
262
+ falling out of favor\cite {FlashKilledOff }.
263
+ Flash was deprecated in 2017 by Adobe, with an end-of-life date of December
264
+ 2020\cite {FlashFuture }.
275
265
276
266
\section {Evolving WebAssembly }
277
267
@@ -281,14 +271,19 @@ \section{Evolving WebAssembly}
281
271
For the release of the 1.0 MVP, the main requirements of being a well-defined
282
272
replacement for asm.js with distributable modules, efficient binary bytecode,
283
273
and high performance were the focus\cite {WasmMvp }.
274
+ Version 1.0 of the specification was tagged on July 20,
275
+ 2019\cite {WasmWg1.0Release }, and focus is now on adding features to increase
276
+ the language's capabilities.
284
277
285
278
Development of the specification takes place in public GitHub repositories.
286
- Version 1.0 of the specification was tagged on July 20,
287
- 2019\cite {WasmWg1.0Release }.
288
279
While a large list of future features are at various levels of consideration
289
280
for post-MVP Wasm, the Community Group and Working Group utilize a phase-based
290
281
proposal system for introducing, discussing, and implementing additional
291
282
features for WebAssembly\cite {WasmFutureFeatures }.
283
+ Proposals may introduce relatively minor behavior changes or describe major
284
+ substantive modifications to the language; no proposal is too small to be
285
+ considered, though larger proposals with greater surface area require more
286
+ deliberation and agreement before being accepted.
292
287
293
288
For a feature to be adopted into the language, a proposal must be drafted which
294
289
passes through a sequence of phases\cite {WasmW3CProcess }:
@@ -311,8 +306,8 @@ \section{Evolving WebAssembly}
311
306
\item [2] \textbf {Proposed Specification Text Available }:
312
307
Once the full proposed English specification text is available in the
313
308
proposal's repository, along with a reasonable community consensus,
314
- prototype implementations for are created so that a test suite can be
315
- added for the new feature .
309
+ prototype implementations for the proposed features are created so that
310
+ a test suite can be added .
316
311
317
312
\item [3] \textbf {Implementation Phase }:
318
313
After a satisfactory test suite is created and passes for the feature
@@ -334,9 +329,8 @@ \section{Evolving WebAssembly}
334
329
335
330
In practice, in order to be deliberate about changes to the language, proposals
336
331
can take a great deal of time before reaching phase 5 and being fully
337
- integrated into the WebAssembly specification.
338
- As of the time of this writing, only five proposals have done
339
- so\cite {FinishedProposals }.
332
+ integrated into the WebAssembly specification; as of the time of this writing
333
+ only five proposals have done so\cite {FinishedProposals }.
340
334
The first such proposal was standardized relatively early in WebAssembly's
341
335
life---prior even to the initial 1.0 release---with the mutable globals
342
336
proposal\cite {MutableGlobalProposal } on June 6,
@@ -352,20 +346,12 @@ \section{Evolving WebAssembly}
352
346
There are 23 currently outstanding proposals: 6 in phase 3, 4 in phase 2,
353
347
9 in phase 1, and 4 in the pre-proposal phase 0\cite {WasmProposals }.
354
348
355
- Proposals may introduce relatively minor behavior changes or describe
356
- major substantive modifications to the language.
357
- No proposal is too small to be considered, though conversely larger
358
- proposals with greater surface area require more deliberation and agreement
359
- before being accepted.
360
-
361
- Proposals may depend on one another.
362
- For example, a notable proposal for Interface Types adds functionality to
363
- describe high-level non-primitive values such as strings or records
364
- so that values of these types can be passed between WebAssembly
365
- modules\cite {InterfaceTypesProposalExplainer }.
366
- Because these types are not primitive value types supported by WebAssembly
367
- such as integers or floating point numbers, there must be way to refer
368
- to these constructs indirectly.
349
+ Proposals may depend on one another: for example, a notable proposal for
350
+ Interface Types adds functionality to describe high-level non-primitive values
351
+ such as strings or records so that values of these types can be passed between
352
+ WebAssembly modules\cite {InterfaceTypesProposalExplainer }.
353
+ Because these types are not of the four primitive value types supported by
354
+ WebAssembly, there must be way to refer to these constructs indirectly.
369
355
Thus, the Interface Types proposal depends on the Reference Types
370
356
proposal, which adds typed reference values for functions and other external
371
357
types\cite {ReferenceTypesProposalOverview }.
@@ -387,8 +373,8 @@ \section{Evolving WebAssembly}
387
373
language are welcome; the only requirement is registering for a W3C account
388
374
and agreeing to the terms of the group.
389
375
The Community Group's meetings and discussions are facilitated primarily using
390
- a dedicated GitHub repository\cite {CGMeetings }.
391
- The Community Group hosts biweekly meetings via video conference.
376
+ a dedicated GitHub repository\cite {CGMeetings }, and it hosts biweekly meetings
377
+ via video conference.
392
378
Meeting minutes and supplemental materials are posted afterward in the
393
379
repository, and off-cycle discussion takes place in the repository's issue
394
380
tracker.
0 commit comments