Skip to content

Commit bbdb216

Browse files
committed
Fork out Web and NonWeb documents.
1 parent d421602 commit bbdb216

File tree

5 files changed

+71
-64
lines changed

5 files changed

+71
-64
lines changed

HighLevelGoals.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
* continue to iteratively specify [additional features](FutureFeatures.md),
1515
prioritized by feedback and experience, including support for languages
1616
other than C/C++.
17-
3. Design to execute within and integrate well with the *existing* Web platform:
17+
3. Design to execute within and integrate well with the *existing*
18+
[Web platform](Web.md):
1819
* maintain the versionless, [feature-tested](FeatureTest.md) and
1920
[backwards-compatible](BinaryEncoding.md#backwards-compatibility)
2021
evolution story of the Web;
@@ -25,8 +26,7 @@
2526
to JavaScript; and
2627
* define a human-editable text format that is convertible to and from the
2728
binary format, supporting View Source functionality.
28-
4. Design to support [non-browser environments](MVP.md#non-browser-embedding)
29-
as well.
29+
4. Design to support [non-browser embeddings](NonWeb.md) as well.
3030
5. Make a great platform:
3131
* build an [LLVM backend](https://github.com/WebAssembly/llvm) and
3232
accompanying [clang port](https://github.com/WebAssembly/clang);

MVP.md

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ post-MVP features doc](EssentialPostMVPFeatures.md).
99
This document explains the contents of the MVP at a high-level. There are also
1010
separate docs with more precise descriptions of:
1111

12-
* the [polyfill to JavaScript](Polyfill.md)
13-
* the [AST semantics](AstSemantics.md)
14-
* the [binary encoding](BinaryEncoding.md)
12+
* [Polyfill to JavaScript](Polyfill.md);
13+
* [AST semantics](AstSemantics.md);
14+
* [Binary encoding](BinaryEncoding.md);
15+
* Implementation [in the browser](Web.md) and [outside the browser](NonWeb.md).
1516

1617
**Note**: This content is still in flux and open for discussion.
1718

@@ -36,6 +37,12 @@ separate docs with more precise descriptions of:
3637
importing, though.
3738
* When compiling from C++, imports would be generated for unresolved `extern`
3839
functions and calls to those `extern` functions would call the import.
40+
* Host environments can define builtin modules that are implemented natively but
41+
can otherwise be imported like [other modules](MVP.md#Modules). As examples:
42+
* A WebAssembly shell might define a builtin `stdio` library with an export
43+
`puts`.
44+
* In the browser, the WebIDL support mentioned in
45+
[future features](FutureFeatures.md).
3946
* **TODO**: there is more to discuss here concerning APIs.
4047

4148
## Module structure
@@ -44,10 +51,10 @@ separate docs with more precise descriptions of:
4451
their type and byte-length.
4552
* Sections with unknown types would be skipped without error.
4653
* Standardized section types:
47-
* module import section (see [Module imports](MVP.md#module-imports) below);
54+
* module import section;
4855
* globals section (constants, signatures, variables);
49-
* code section (see [Code section](MVP.md#code-section) below);
50-
* heap initialization section (see [Heap](MVP.md#heap) below).
56+
* code section;
57+
* heap initialization section.
5158

5259
## Code section
5360

@@ -93,38 +100,6 @@ isomorphic to the [binary format](BinaryEncoding.md).
93100
* See the [AST Semantics heap section](AstSemantics.md#accessing-the-heap) for
94101
more details.
95102

96-
## Non-browser embedding
97-
98-
* Host environments can define builtin modules that are implemented natively but
99-
can otherwise be imported like
100-
[other modules](MVP.md#code-loading-and-imports). As examples:
101-
* A WebAssembly shell might define a builtin `stdio` library with an export
102-
`puts`.
103-
* In the browser, the WebIDL support mentioned in
104-
[future features](FutureFeatures.md).
105-
* Where there is overlap between the browser and popular non-browser
106-
environments, a shared spec could be proposed, but this would be separate
107-
from the WebAssembly spec.
108-
* A symmetric example in JavaScript would be the
109-
[Loader](http://whatwg.github.io/loader) spec, intended to be implemented by
110-
both browsers and node.js.
111-
* However, one might find a fair amount of variance between the browser and
112-
other environments on core APIs like network and file I/O.
113-
* To allow writing portable POSIX-like code (that ran in both browser and other
114-
environments), the WebAssembly community would develop a shared repository of
115-
WebAssembly code that mapped between a POSIX-like interface and the host's
116-
builtin modules using compile-time `#ifdef`s or, after
117-
[dynamic linking](FutureFeatures.md#dynamic-linking) was added, client-side
118-
dynamic feature testing.
119-
* A symmetric example in JavaScript would be the
120-
[ES6 Module Loader polyfill](https://github.com/ModuleLoader/es6-module-loader)
121-
library.
122-
* The WebAssembly spec would thus not try to define any large portable
123-
libc-like library.
124-
* However, certain features that are core to WebAssembly semantics that are
125-
found in native libc *would* be part of the core WebAssembly spec as either
126-
primitive opcodes or a special builtin module (e.g., `sbrk`, `mmap`).
127-
128103
## Security
129104

130105
WebAssembly MVP will be no looser from a security point-of-view than if the

NonWeb.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Non-Browser Embeddings
2+
3+
WebAssembly is designed to run primarily [within a browser](Web.md). It is
4+
nonetheless desirable to be able to execute it inside standalone shells for
5+
testing and as a host environment for untrusted code (e.g. in a datacenter). It
6+
may even be desirable to execute WebAssembly embedded within larger programs.
7+
8+
Non-browser environments may have access to different APIs, which
9+
[feature testing](FeatureTest.md) and
10+
[dynamic linking](FutureFeatures.md#dynamic-linking) will make discoverable and
11+
usable.
12+
13+
Where there is overlap between the browser and popular non-browser environments,
14+
a shared spec could be proposed, but this would be separate from the WebAssembly
15+
spec. A symmetric example in JavaScript would be the
16+
[Loader](http://whatwg.github.io/loader) spec, intended to be implemented by
17+
both browsers and node.js. This situation is expected to be first encountered
18+
with POSIX features such as file I/O. In that respect, WebAssembly would err
19+
towards standardizing existing practice through libraries, and let developers
20+
choose which libraries to use.
21+
22+
The WebAssembly spec will not try to define any large portable libc-like
23+
library. However, certain features that are core to WebAssembly semantics that
24+
are found in native libc *would* be part of the core WebAssembly spec as either
25+
primitive opcodes or a special builtin module (e.g., `sbrk`, `mmap`).

Polyfill.md

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,9 @@ as well as to convert [asm.js](http://asmjs.org) into WebAssembly (useful
2121
for existing applications), is in the [polyfill repo](https://github.com/WebAssembly/polyfill).
2222
We also leave open the possibility of multiple polyfills existing to meet different developers' needs.
2323

24-
## Implementation Details
25-
2624
An **effective** polyfill should reuse much of the Web platform's existing
27-
capabilities.
28-
29-
We've identified interesting polyfill implementation approaches which help
30-
convince us that the design, especially that of the MVP, are sensible:
31-
32-
* A [module](MVP.md#Modules) can be loaded in the same way as an ES6 module
33-
(`import` statements, `Reflect` API, `Worker` constructor, etc) and the result
34-
is reflected to JS as an ES6 module object.
35-
* Exports are the ES6 module object exports.
36-
* An import first passes the module name to the
37-
[module loader pipeline](http://whatwg.github.io/loader) and resulting ES6
38-
module (which could be implemented in JS or WebAssembly) is queried for the
39-
export name.
40-
* There is no special case for when one WebAssembly module imports another:
41-
they have separate [heaps](MVP.md#heap) and pointers cannot be passed
42-
between the two. Module imports encapsulate the importer and importee.
43-
* To synchronously call into JavaScript from C++, the C++ code would declare
44-
and call an undefined `extern` function and the target JavaScript function
45-
would be given the (mangled) name of the `extern` and put inside the
46-
imported ES6 module.
47-
25+
capabilities, as detailed in the browser embedding
26+
[implementation details](Web.md#Implementation-Details).
4827

4928
## Polyfill Deviations
5029

Web.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Browser Embedding
2+
3+
WebAssembly is [originally](MVP.md) targetted at being embedded in browsers as
4+
an integral part of the Web platform.
5+
6+
A key part of operating on the web is supporting
7+
[feature testing](FeatureTest.md).
8+
9+
# Implementation Details
10+
11+
We've identified interesting implementation approaches which help convince us
12+
that the design, especially that of the [MVP](MVP.md), are sensible:
13+
14+
* A [module](MVP.md#Modules) can be loaded in the same way as an ES6 module
15+
(`import` statements, `Reflect` API, `Worker` constructor, etc) and the result
16+
is reflected to JS as an ES6 module object.
17+
* Exports are the ES6 module object exports.
18+
* An import first passes the module name to the
19+
[module loader pipeline](http://whatwg.github.io/loader) and resulting ES6
20+
module (which could be implemented in JS or WebAssembly) is queried for the
21+
export name.
22+
* There is no special case for when one WebAssembly module imports another:
23+
they have separate [heaps](MVP.md#heap) and pointers cannot be passed
24+
between the two. Module imports encapsulate the importer and importee.
25+
* To synchronously call into JavaScript from C++, the C++ code would declare
26+
and call an undefined `extern` function and the target JavaScript function
27+
would be given the (mangled) name of the `extern` and put inside the
28+
imported ES6 module.

0 commit comments

Comments
 (0)