Skip to content

Commit 4695ec3

Browse files
authored
Merge reference-types/master
Update to reference-types/master
2 parents 2906531 + 7fd2533 commit 4695ec3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3081
-1086
lines changed

.travis.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ dist: bionic
66
addons:
77
apt:
88
sources:
9+
- sourceline: 'ppa:avsm/ppa'
910
- sourceline: 'deb https://dl.yarnpkg.com/debian/ stable main'
1011
key_url: 'https://dl.yarnpkg.com/debian/pubkey.gpg'
12+
update: true
1113
packages:
12-
- ocaml
13-
- ocamlbuild
14+
- opam
1415
- texlive-full
1516
- yarn
1617

1718
install:
19+
- opam init --auto-setup --compiler=4.07.1
20+
- eval $(opam env)
21+
- opam --version
22+
- ocaml --version
23+
- opam install --yes ocamlbuild.0.14.0
1824
- pip install Sphinx==2.4.4
1925
- git clone https://github.com/tabatkins/bikeshed.git
2026
- pip install --editable $PWD/bikeshed

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@ specification language.
2222
It also holds the WebAssembly testsuite, which tests numerous aspects of
2323
conformance to the spec.
2424

25-
View the work-in-progress spec at
26-
[webassembly.github.io/spec](https://webassembly.github.io/spec/).
25+
View the work-in-progress spec at [webassembly.github.io/spec](https://webassembly.github.io/spec/).
2726

2827
At this time, the contents of this repository are under development and known
2928
to be "incomplet and inkorrect".
3029

3130
Participation is welcome. Discussions about new features, significant semantic
3231
changes, or any specification change likely to generate substantial discussion
33-
should take place in [the WebAssembly design
34-
repository](https://github.com/WebAssembly/design) first, so that this spec
35-
repository can remain focused. And please follow the [guidelines for
36-
contributing](Contributing.md).
32+
should take place in
33+
[the WebAssembly design repository](https://github.com/WebAssembly/design)
34+
first, so that this spec repository can remain focused. And please follow the
35+
[guidelines for contributing](Contributing.md).
36+
37+
# citing
38+
39+
For citing WebAssembly in LaTeX, use [this bibtex file](wasm-specs.bib).

document/README.md

+95
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,98 @@ To build everything and update [webassembly.github.io/spec](https://webassembly.
2121
make publish
2222
```
2323
Please make sure to only use that once a change has approval.
24+
25+
## Step by step guide to building the spec
26+
27+
### Prerequisites
28+
29+
You will need `python3.7`, and `pip`. `pip` should come with Python, if not follow [these installation instructions for `pip`](https://pip.pypa.io/en/stable/installing/), or check your system package manager for `pip3`.
30+
31+
> Important: you will need the version of pip that works with `python3.7`.
32+
33+
34+
Use something like [`pipenv`](https://pipenv.pypa.io/) to keep your system installation of Python clean.
35+
36+
```
37+
pip install pipenv
38+
pipenv --python 3.7
39+
pipenv shell
40+
```
41+
42+
Install Python dependencies:
43+
44+
```
45+
pip install Sphinx==2.4.4
46+
```
47+
48+
### Checking out the repository
49+
50+
Make sure this repository was cloned with `--recursive`:
51+
52+
```
53+
git clone --recursive https://github.com/WebAssembly/spec
54+
```
55+
56+
If you have already cloned but without `--recursive`, you can delete and re-clone, or `cd` into `spec` and run:
57+
58+
```
59+
git submodule update --init --recursive
60+
```
61+
62+
The rest of these instructions assume you are in the directory where is README is:
63+
64+
```
65+
cd spec/document
66+
```
67+
68+
### Building the multi-page HTML document
69+
70+
You can now build the [multi-page html document](https://webassembly.github.io/spec/core/):
71+
72+
```
73+
make -C core html
74+
```
75+
76+
### Building the single-page HTML document
77+
78+
To build the [single-page W3C version](https://webassembly.github.io/spec/core/bikeshed/), there are more dependencies to install. First, get [Bikeshed](https://github.com/tabatkins/bikeshed):
79+
80+
```
81+
# cd back to root of git directory
82+
git clone https://github.com/tabatkins/bikeshed.git
83+
pip install --editable bikeshed
84+
bikeshed update
85+
```
86+
87+
You will also need `npm` and `yarn` for all the LaTeX goodness. `npm` might already be available on your system, you can also use something like [`nvm`](https://github.com/nvm-sh/nvm) to prevent messing with system packages:
88+
89+
```
90+
npm install -g yarn
91+
cd document
92+
make -C core bikeshed
93+
```
94+
95+
### Building the PDF
96+
97+
To build the [PDF](https://webassembly.github.io/spec/core/_download/WebAssembly.pdf), you will need `texlive-full`, install it using your system package manager:
98+
99+
```
100+
apt install texlive-full
101+
make -C core pdf
102+
```
103+
104+
### Building the JavaScript Embedding API
105+
106+
To build the [JavaScript Embedding API](https://webassembly.github.io/spec/js-api/index.html), you will need `bikeshed` as describe in the section [Building the single-page HTML document](#building-the-single-page-html-document):
107+
108+
```
109+
make -C js-api
110+
```
111+
112+
### Building the Web Embedding API
113+
114+
To build the [Web Embedding API](https://webassembly.github.io/spec/web-api/index.html), you will need `bikeshed` as describe in the section [Building the single-page HTML document](#building-the-single-page-html-document):
115+
116+
```
117+
make -C web-api
118+
```

document/core/Makefile

+6-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ bikeshed-keep:
8989
echo Downloaded Bikeshed.
9090

9191

92+
.PHONY: index
93+
index:
94+
(cd appendix; ./gen-index-instructions.py)
95+
9296
.PHONY: pdf
93-
pdf: latexpdf
97+
pdf: index latexpdf
9498
mkdir -p $(BUILDDIR)/html/$(DOWNLOADDIR)
9599
ln -f $(BUILDDIR)/latex/$(NAME).pdf $(BUILDDIR)/html/$(DOWNLOADDIR)/$(NAME).pdf
96100

@@ -101,7 +105,7 @@ clean:
101105
rm -rf $(STATICDIR)
102106

103107
.PHONY: html
104-
html:
108+
html: index
105109
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
106110
for file in `ls $(BUILDDIR)/html/*.html`; \
107111
do \

document/core/appendix/algorithm.rst

+11-8
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ Types are representable as an enumeration.
2727
2828
type val_type = I32 | I64 | F32 | F64 | Funcref | Exnref | Externref
2929
30-
func is_num(t : val_type) : bool =
31-
return t = I32 || t = I64 || t = F32 || t = F64
30+
func is_num(t : val_type | Unknown) : bool =
31+
return t = I32 || t = I64 || t = F32 || t = F64 || t = Unknown
3232
33-
func is_ref(t : val_type) : bool =
34-
return t = Funcref || t = Exnref || t = Externref
33+
func is_ref(t : val_type | Unknown) : bool =
34+
return t = Funcref || t = Exnref || t = Externref || t = Unknown
3535
3636
The algorithm uses two separate stacks: the *value stack* and the *control stack*.
3737
The former tracks the :ref:`types <syntax-valtype>` of operand values on the :ref:`stack <stack>`,
@@ -52,7 +52,6 @@ the latter surrounding :ref:`structured control instructions <syntax-instr-contr
5252
5353
For each value, the value stack records its :ref:`value type <syntax-valtype>`, or :code:`Unknown` when the type is not known.
5454

55-
5655
For each entered block, the control stack records a *control frame* with the originating opcode, the types on the top of the operand stack at the start and end of the block (used to check its result as well as branches), the height of the operand stack at the start of the block (used to check that operands do not underflow the current block), and a flag recording whether the remainder of the block is unreachable (used to handle :ref:`stack-polymorphic <polymorphism>` typing after branches).
5756

5857
For the purpose of presenting the algorithm, the operand and control stacks are simply maintained as global variables:
@@ -231,13 +230,17 @@ Other instructions are checked in a similar manner.
231230
      push_vals(label_types(ctrls[n]))
232231
233232
   case (br_table n* m)
233+
pop_val(I32)
234234
      error_if(ctrls.size() < m)
235+
let arity = label_types(ctrls[m]).size()
235236
      foreach (n in n*)
236-
        error_if(ctrls.size() < n || label_types(ctrls[n]) =/= label_types(ctrls[m]))
237-
pop_val(I32)
238-
      pop_vals(label_types(ctrls[m]))
237+
        error_if(ctrls.size() < n)
238+
        error_if(label_types(ctrls[n]).size() =/= arity)
239+
push_vals(pop_vals(label_types(ctrls[n])))
240+
pop_vals(label_types(ctrls[m]))
239241
      unreachable()
240242
243+
241244
.. note::
242245
It is an invariant under the current WebAssembly instruction set that an operand of :code:`Unknown` type is never duplicated on the stack.
243246
This would change if the language were extended with stack instructions like :code:`dup`.

0 commit comments

Comments
 (0)