11# Features to add after the MVP
22
33These are features that make sense in the context of the
4- [ high-level goals] ( HighLevelGoals.md ) of WebAssembly but are not considered part
5- of the [ Minimum Viable Product] ( MVP.md ) or the essential
6- [ post-MVP : unicorn : ] ( PostMVP.md )
7- feature set which are expected to be standardized immediately after the
8- MVP. These will be prioritized based on developer feedback, and will be
4+ [ high-level goals] ( HighLevelGoals.md ) of WebAssembly but won't be part of the
5+ initial [ Minimum Viable Product] ( MVP.md ) release.
6+
7+ We expect several essential features to be standardized immediately after the
8+ MVP. Others will be prioritized based on developer feedback, and all will be
99available under [ feature tests] ( FeatureTest.md ) .
1010
11- ## Great tooling support
11+ :star : = Essential features we want to prioritize adding shortly after
12+ the [ MVP] ( MVP.md ) .
13+
14+ ## On Deck for Immediate Design
15+
16+ ### Great tooling support :star : :star : :star :
1217
1318This is covered in the [ tooling] ( Tooling.md ) section.
1419
15- ## Finer-grained control over memory
20+ ### Threads :star : :star :
21+
22+ Provide low-level buildings blocks for pthreads-style shared memory: shared
23+ memory between threads, atomics and futexes (or [ synchronic] [ ] ).
24+
25+ New atomic memory operators, including loads/stores annotated with their atomic
26+ ordering property, will follow the [ C++11 memory model] [ ] , similarly to the
27+ [ PNaCl atomic support] [ ] and the [ SharedArrayBuffer] [ ] proposal. Regular loads
28+ and stores will be bound by a happens-before relationship to atomic operators
29+ in the same thread of execution, which themselves synchronize-with atomics in
30+ other threads. Following these rules, regular load/store operators can still be
31+ elided, duplicated, and split up. This guarantees that data-race free code
32+ executes as if it were sequentially consistent. Even when there are data races,
33+ WebAssembly will ensure that the [ nondeterminism] ( Nondeterminism.md ) remains
34+ limited and local.
35+
36+ Modules can have thread-local variables that are disjoint from linear memory
37+ and can thus be represented efficiently by the engine.
38+
39+ [ synchronic ] : http://wg21.link/n4195
40+ [ C++11 memory model ] : http://www.hboehm.info/c++mm/
41+ [ PNaCl atomic support ] : https://developer.chrome.com/native-client/reference/pnacl-c-cpp-language-support#memory-model-and-atomics
42+ [ SharedArrayBuffer ] : https://github.com/tc39/ecmascript_sharedmem
43+
44+ ### Fixed-width SIMD :star :
45+
46+ Support fixed-width SIMD vectors, initially only for 128-bit wide vectors as
47+ demonstrated in [ PNaCl's SIMD] [ ] and [ SIMD.js] [ ] .
48+
49+ SIMD adds new local types (e.g., ` f32x4 ` ) so it has to be part of the core
50+ semantics. SIMD operators (e.g., ` f32x4.add ` ) could be either builtin
51+ operators (no different from ` i32.add ` ) or exports of a builtin SIMD module.
52+
53+ [ PNaCl's SIMD ] : https://developer.chrome.com/native-client/reference/pnacl-c-cpp-language-support#portable-simd-vectors
54+ [ SIMD.js ] : https://github.com/tc39/ecmascript_simd
55+
56+ ### Zero-cost Exception Handling :star :
57+
58+ The WebAssembly MVP may support four no-exception
59+ modes for C++:
60+
61+ * Compiler transforms ` throw ` to ` abort() ` .
62+ * Compiler-enforced ` -fno-exceptions ` mode (note [ caveats] [ ] ).
63+ * Compiler conversion of exceptions to branching at all callsites.
64+ * In a Web environment exception handling can be emulated using JavaScript
65+ exception handling, which can provide correct semantics but isn't fast.
66+
67+ These modes are suboptimal for code bases which rely on C++ exception handling,
68+ but are perfectly acceptable for C code, or for C++ code which avoids
69+ exceptions. This doesn't prevent developers from using the C++ standard library:
70+ their code will function correctly (albeit slower at times) as long as it
71+ doesn't encounter exceptional cases.
72+
73+ Post-MVP, WebAssembly will gain support for developer access to stack unwinding,
74+ inspection, and limited manipulation. These are critical to supporting zero-cost
75+ exception handling by exposing [ low-level capabilities] [ ] .
76+
77+ In turn, stack unwinding, inspection, and limited manipulation will be used to
78+ implement ` setjmp ` /` longjmp ` . This can enable all of the defined behavior of
79+ ` setjmp ` /` longjmp ` , namely unwinding the stack without calling C++
80+ destructors. It does not, however, allow the undefined behavior case of jumping
81+ forward to a stack that was already unwound which is sometimes used to implement
82+ coroutines. Coroutine support is being
83+ [ considered separately] ( FutureFeatures.md#coroutines ) .
84+
85+ [ caveats ] : https://blog.mozilla.org/nnethercote/2011/01/18/the-dangers-of-fno-exceptions
86+ [ low-level capabilities ] : https://extensiblewebmanifesto.org
87+
88+ ### Feature Testing :star :
89+
90+ Post-MVP, some form of feature-testing will be required. We don't yet have the
91+ experience writing polyfills to know whether ` has_feature ` is the right
92+ primitive building block so we're not defining it (or something else) until we
93+ gain this experience. In the interim, it's possible to do a crude feature test
94+ (as people do in JavaScript) by just ` eval ` -ing WebAssembly code and catching
95+ validation errors.
96+
97+ See [ Feature test] ( FeatureTest.md ) for a more detailed sketch.
98+
99+ ## Proposals we might consider in the future
100+
101+ ### Finer-grained control over memory
16102
17103Provide access to safe OS-provided functionality including:
18104
@@ -49,13 +135,13 @@ provided by the `mmap` OS primitive. One significant exception is that `mmap`
49135can allocate noncontiguous virtual address ranges. See the
50136[ FAQ] ( FAQ.md#what-about-mmap ) for rationale.
51137
52- ## Large page support
138+ ### Large page support
53139
54140Some platforms offer support for memory pages as large as 16GiB, which
55141can improve the efficiency of memory management in some situations. WebAssembly
56142may offer programs the option to specify a larger page size than the [ default] ( Semantics.md#resizing ) .
57143
58- ## More expressive control flow
144+ ### More expressive control flow
59145
60146Some types of control flow (especially irreducible and indirect) cannot be
61147expressed with maximum efficiency in WebAssembly without patterned output by the
@@ -76,11 +162,11 @@ Options under consideration:
76162 making it easier to support other languages, especially functional programming
77163 languages.
78164
79- ## GC/DOM Integration
165+ ### GC/DOM Integration
80166
81167See [ GC.md] ( GC.md ) .
82168
83- ## Linear memory bigger than 4 GiB
169+ ### Linear memory bigger than 4 GiB
84170
85171The WebAssembly MVP will support the wasm32 mode of WebAssembly, with linear
86172memory sizes up to 4 GiB using 32-bit linear memory indices. To support larger
@@ -101,7 +187,7 @@ instance. However, operators with 32-bit indices and operators with 64-bit
101187indices will be given separate names to leave open the possibility of
102188supporting both in the same instance in the future.
103189
104- ## Source maps integration
190+ ### Source maps integration
105191
106192* Add a new source maps [ module section type] ( MVP.md#module-structure ) .
107193* Either embed the source maps directly or just a URL from which source maps can
@@ -111,14 +197,14 @@ supporting both in the same instance in the future.
111197* Gestate ideas and start discussions at the
112198 [ Source Map RFC repository] ( https://github.com/source-map/source-map-rfc/issues )
113199
114- ## Coroutines
200+ ### Coroutines
115201
116202Coroutines will [ eventually be part of C++] [ ] and is already popular in other
117203programming languages that WebAssembly will support.
118204
119205 [ eventually be part of C++ ] : http://wg21.link/n4499
120206
121- ## Signature-restricted Proper Tail Calls
207+ ### Signature-restricted Proper Tail Calls
122208
123209See the [ asm.js RFC] [ ] for a full description of signature-restricted Proper
124210Tail Calls (PTC).
@@ -139,18 +225,18 @@ Useful properties of signature-restricted PTCs:
139225
140226 [ asm.js RFC ] : http://discourse.specifiction.org/t/request-for-comments-add-a-restricted-subset-of-proper-tail-calls-to-asm-js
141227
142- ## General-purpose Proper Tail Calls
228+ ### General-purpose Proper Tail Calls
143229
144230General-purpose Proper Tail Calls would have no signature restrictions, and
145231therefore be more broadly usable than
146232[ Signature-restricted Proper Tail Calls] ( Semantics.md#signature-restricted-proper-tail-calls ) ,
147233though there would be some different performance characteristics.
148234
149- ## Asynchronous Signals
235+ ### Asynchronous Signals
150236
151237TODO
152238
153- ## "Long SIMD"
239+ ### "Long SIMD"
154240
155241The initial SIMD API will be a "short SIMD" API, centered around fixed-width
156242128-bit types and explicit SIMD operators. This is quite portable and useful,
@@ -176,7 +262,7 @@ include:
176262
177263 [ a proposal in the SIMD.js repository ] : https://github.com/tc39/ecmascript_simd/issues/180
178264
179- ## Platform-independent Just-in-Time (JIT) compilation
265+ ### Platform-independent Just-in-Time (JIT) compilation
180266
181267WebAssembly is a new virtual ISA, and as such applications won't be able to
182268simply reuse their existing JIT-compiler backends. Applications will instead
@@ -205,13 +291,13 @@ are use cases for higher-level functionality and optimization too. One avenue
205291for addressing these use cases is a
206292[ JIT and Optimization library] ( JITLibrary.md ) .
207293
208- ## Multiprocess support
294+ ### Multiprocess support
209295
210296* ` vfork ` .
211297* Inter-process communication.
212298* Inter-process ` mmap ` .
213299
214- ## Trapping or non-trapping strategies.
300+ ### Trapping or non-trapping strategies.
215301
216302Presently, when an instruction traps, the program is immediately terminated.
217303This suits C/C++ code, where trapping conditions indicate Undefined Behavior at
@@ -236,7 +322,7 @@ use cases:
236322 resuming execution at the trapping instruction with the execution state
237323 altered, if there can be a reasonable way to specify how that should work.
238324
239- ## Additional integer operators
325+ ### Additional integer operators
240326
241327* The following operators can be built from other operators already present,
242328 however in doing so they read at least one non-constant input multiple times,
@@ -259,7 +345,7 @@ use cases:
259345 * ` i64.mor ` : sign-agnostic [ 8x8 bit-matrix multiply with or] ( http://mmix.cs.hm.edu/doc/instructions-en.html#MOR )
260346 * ` i64.mxor ` : sign-agnostic [ 8x8 bit-matrix multiply with xor] ( http://mmix.cs.hm.edu/doc/instructions-en.html#MXOR )
261347
262- ## Additional floating point operators
348+ ### Additional floating point operators
263349
264350 * ` f32.minnum ` : minimum; if exactly one operand is NaN, returns the other operand
265351 * ` f32.maxnum ` : maximum; if exactly one operand is NaN, returns the other operand
@@ -275,7 +361,7 @@ Note that some operators, like `fma`, may not be available or may not perform
275361well on all platforms. These should be guarded by
276362[ feature tests] ( FeatureTest.md ) so that if available, they behave consistently.
277363
278- ## Floating point approximation operators
364+ ### Floating point approximation operators
279365
280366 * ` f32.reciprocal_approximation ` : reciprocal approximation
281367 * ` f64.reciprocal_approximation ` : reciprocal approximation
@@ -285,7 +371,7 @@ well on all platforms. These should be guarded by
285371These operators would not required to be fully precise, but the specifics
286372would need clarification.
287373
288- ## 16-bit and 128-bit floating point support
374+ ### 16-bit and 128-bit floating point support
289375
290376For 16-bit floating point support, it may make sense to split the feature
291377into two parts: support for just converting between 16-bit and 32-bit or
@@ -301,7 +387,7 @@ techniques such as double-double arithmetic. If we standardize 128-bit
301387floating point in WebAssembly, it will probably be standard IEEE 754-2008
302388quadruple precision.
303389
304- ## Full IEEE 754-2008 conformance
390+ ### Full IEEE 754-2008 conformance
305391
306392WebAssembly floating point conforms IEEE 754-2008 in most respects, but there
307393are a few areas that are
@@ -333,15 +419,15 @@ enabled only from developer tools, that would enable traps on selected floating
333419point exceptions, however care should be taken, since not all floating point
334420exceptions indicate bugs.
335421
336- ## Flushing Subnormal Values to Zero
422+ ### Flushing Subnormal Values to Zero
337423
338424Many popular CPUs have significant stalls when processing subnormal values,
339425and support modes where subnormal values are flushed to zero which avoid
340426these stalls. And, ARMv7 NEON has no support for subnormal values and always
341427flushes them. A mode where floating point computations have subnormals flushed
342428to zero in WebAssembly would address these two issues.
343429
344- ## Integer Overflow Detection
430+ ### Integer Overflow Detection
345431
346432There are two different use cases here, one where the application wishes to
347433handle overflow locally, and one where it doesn't.
@@ -371,7 +457,7 @@ general-purpose use on several of today's popular hardware architectures.
371457
372458 [ handle trap specially ] : FutureFeatures.md#trapping-or-non-trapping-strategies
373459
374- ## Better feature testing support
460+ ### Better feature testing support
375461
376462The [ MVP feature testing situation] ( FeatureTest.md ) could be improved by
377463allowing unknown/unsupported instructions to decode and validate. The runtime
@@ -382,7 +468,7 @@ lighter-weight alternative to load-time polyfilling (approach 2 in
382468were to be standardized and performed natively such that no user-space translation
383469pass was otherwise necessary.
384470
385- ## Mutable global variables
471+ ### Mutable global variables
386472
387473In the MVP, there are no global variables; C/C++ global variables are stored in
388474linear memory and thus accessed through normal
@@ -397,7 +483,7 @@ reduce fragmentation issues. Languages like Fortran which limit aliasing would b
397483one use case. C/C++ compilers could also determine that some global variables never
398484have their address taken.
399485
400- ## Streaming Compilation
486+ ### Streaming Compilation
401487
402488The WebAssembly binary format is designed to allow streaming decoding,
403489validation and compilation. In the MVP, however, the only way to compile
@@ -421,12 +507,12 @@ of WebAssembly in browsers:
421507 custom compression (on top of the spec-defined binary format, under generic
422508 HTTP ` Content-Encoding ` compression).
423509
424- ## Multiple Return
510+ ### Multiple Return
425511
426512The stack based nature of WebAssembly lends itself to the possibility
427513of supporting multiple return values from blocks / functions.
428514
429- ## Multiple Tables and Memories
515+ ### Multiple Tables and Memories
430516
431517The MVP limits modules to at most one memory and at most one table (the default
432518ones) and there are only operators for accessing the default table and memory.
@@ -444,7 +530,7 @@ would return a first-class reference. Beyond tables and memories, this could
444530also be used for function definitions to get a reference to a function (which,
445531since opaque, could be implemented as a raw function pointer).
446532
447- ## More Table Operators and Types
533+ ### More Table Operators and Types
448534
449535In the MVP, WebAssembly has limited functionality for operating on
450536[ tables] ( Semantics.md#table ) and the host-environment can do much more (e.g.,
0 commit comments