Skip to content

Commit e75f3b2

Browse files
authored
Merge upstream (#55)
1 parent 9b0e240 commit e75f3b2

File tree

203 files changed

+101671
-1327
lines changed

Some content is hidden

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

203 files changed

+101671
-1327
lines changed

.github/workflows/main.yml

+10-16
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ main ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ main ]
88

99
# Allows you to run this workflow manually from the Actions tab
1010
workflow_dispatch:
@@ -25,29 +25,23 @@ jobs:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@v2
28-
- name: Build JS API bikeshed
29-
uses: netwerk-digitaal-erfgoed/bikeshed-action@v1
30-
with:
31-
source: "document/js-api/index.bs"
32-
destination: "document/js-api/index.html"
28+
- run: pip install bikeshed && bikeshed update
29+
- run: bikeshed spec "document/js-api/index.bs" "document/js-api/index.html"
3330
- uses: actions/upload-artifact@v2
3431
with:
3532
name: js-api-rendered
36-
path: document/js-api
33+
path: document/js-api/index.html
3734

3835
build-web-api-spec:
3936
runs-on: ubuntu-latest
4037
steps:
4138
- uses: actions/checkout@v2
42-
- name: Build JS API bikeshed
43-
uses: netwerk-digitaal-erfgoed/bikeshed-action@v1
44-
with:
45-
source: "document/web-api/index.bs"
46-
destination: "document/web-api/index.html"
39+
- run: pip install bikeshed && bikeshed update
40+
- run: bikeshed spec "document/web-api/index.bs" "document/web-api/index.html"
4741
- uses: actions/upload-artifact@v2
4842
with:
4943
name: web-api-rendered
50-
path: document/web-api
44+
path: document/web-api/index.html
5145

5246
build-core-spec:
5347
runs-on: ubuntu-latest
@@ -58,7 +52,7 @@ jobs:
5852
- run: pip install bikeshed && bikeshed update
5953
- run: pip install six
6054
- run: sudo apt-get update -y && sudo apt-get install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
61-
- run: pip install sphinx==3.5.2
55+
- run: pip install sphinx==4.0.0
6256
- run: cd document/core && make all
6357
- uses: actions/upload-artifact@v2
6458
with:
@@ -84,7 +78,7 @@ jobs:
8478
name: core-api-rendered
8579
path: _output/core
8680
- name: Publish HTML to GitHub Pages
87-
if: github.ref == 'refs/heads/master'
81+
if: github.ref == 'refs/heads/main'
8882
uses: peaceiris/actions-gh-pages@v3
8983
with:
9084
publish_dir: ./_output

.github/workflows/mirror.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
on:
2+
push:
3+
branches:
4+
- 'main'
5+
6+
jobs:
7+
mirror_job:
8+
runs-on: ubuntu-latest
9+
name: Mirror main branch to master branch
10+
steps:
11+
- name: Mirror action step
12+
id: mirror
13+
uses: google/[email protected]
14+
with:
15+
github-token: ${{ secrets.GITHUB_TOKEN }}
16+
source: 'main'
17+
dest: 'master'

Contributing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
Interested in participating? Please follow
44
[the same contributing guidelines as the design repository][].
55

6-
[the same contributing guidelines as the design repository]: https://github.com/WebAssembly/design/blob/master/Contributing.md
6+
[the same contributing guidelines as the design repository]: https://github.com/WebAssembly/design/blob/main/Contributing.md
77

88
Also, please be sure to read [the README.md](README.md) for this repository.

document/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pipenv shell
4242
Install Python dependencies:
4343

4444
```
45-
pipenv install Sphinx==3.5.2
45+
pipenv install Sphinx==4.0.0
4646
```
4747

4848
### Checking out the repository

document/core/appendix/algorithm.rst

+44-39
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@ Types are representable as a set of enumerations.
2626
.. code-block:: pseudo
2727
2828
type num_type = I32 | I64 | F32 | F64
29+
type vec_type = V128
2930
type heap_type = Def(idx : nat) | Func | Extern | Bot
3031
type ref_type = Ref(heap : heap_type, null : bool)
31-
type val_type = num_type | ref_type | Bot
32+
type val_type = num_type | vec_type | ref_type | Bot
3233
3334
func is_num(t : val_type) : bool =
3435
return t = I32 || t = I64 || t = F32 || t = F64 || t = Bot
3536
36-
func is_ref(t : val_type) : bool =
37-
return t = not (is_num t) || t = Bot
37+
func is_vec(t : val_type | Unknown) : bool =
38+
return t = V128 || t = Unknown
39+
40+
func is_ref(t : val_type | Unknown) : bool =
41+
return t = not (is_num t || is_vec t) || t = Bot
3842
3943
Equivalence and subtyping checks can be defined on these types.
4044

@@ -105,6 +109,11 @@ However, these variables are not manipulated directly by the main checking funct
105109
error_if(vals.size() = ctrls[0].height)
106110
return vals.pop()
107111
112+
func pop_val(expect : val_type) : val_type =
113+
let actual = pop_val()
114+
error_if(not matches(actual, expect))
115+
return actual
116+
108117
func pop_num() : num_type | Bot =
109118
let actual = pop_val()
110119
error_if(not is_num(actual))
@@ -116,15 +125,10 @@ However, these variables are not manipulated directly by the main checking funct
116125
if actual = Bot then return Ref(Bot, false)
117126
return actual
118127
119-
func pop_val(expect : val_type) : val_type =
120-
let actual = pop_val()
121-
error_if(not matches(actual, expect))
122-
return actual
123-
124128
func push_vals(types : list(val_type)) = foreach (t in types) push_val(t)
125129
func pop_vals(types : list(val_type)) : list(val_type) =
126130
var popped := []
127-
foreach (t in reverse(types)) popped.append(pop_val(t))
131+
foreach (t in reverse(types)) popped.prepend(pop_val(t))
128132
return popped
129133
130134
Pushing an operand value simply pushes the respective type to the value stack.
@@ -150,24 +154,24 @@ The control stack is likewise manipulated through auxiliary functions:
150154
.. code-block:: pseudo
151155
152156
func push_ctrl(opcode : opcode, in : list(val_type), out : list(val_type)) =
153-
 let frame = ctrl_frame(opcode, in, out, vals.size(), false)
154-
  ctrls.push(frame)
157+
let frame = ctrl_frame(opcode, in, out, vals.size(), false)
158+
ctrls.push(frame)
155159
push_vals(in)
156160
157161
func pop_ctrl() : ctrl_frame =
158-
 error_if(ctrls.is_empty())
159-
 let frame = ctrls[0]
160-
  pop_vals(frame.end_types)
161-
  error_if(vals.size() =/= frame.height)
162+
error_if(ctrls.is_empty())
163+
let frame = ctrls[0]
164+
pop_vals(frame.end_types)
165+
error_if(vals.size() =/= frame.height)
162166
ctrls.pop()
163-
  return frame
167+
return frame
164168
165169
func label_types(frame : ctrl_frame) : list(val_types) =
166170
return (if frame.opcode == loop then frame.start_types else frame.end_types)
167171
168172
func unreachable() =
169-
  vals.resize(ctrls[0].height)
170-
  ctrls[0].unreachable := true
173+
vals.resize(ctrls[0].height)
174+
ctrls[0].unreachable := true
171175
172176
Pushing a control frame takes the types of the label and result values.
173177
It allocates a new frame record recording them along with the current height of the operand stack and marks the block as reachable.
@@ -213,10 +217,11 @@ Other instructions are checked in a similar manner.
213217
214218
case (select)
215219
pop_val(I32)
216-
let t1 = pop_num()
217-
let t2 = pop_num()
220+
let t1 = pop_val()
221+
let t2 = pop_val()
222+
error_if(not (is_num(t1) && is_num(t2) || is_vec(t1) && is_vec(t2)))
218223
error_if(t1 =/= t2 && t1 =/= Bot && t2 =/= Bot)
219-
push_val(if (t1 = Bot) t2 else t1)
224+
push_val(if (t1 == Bot) t2 else t1)
220225
221226
case (select t)
222227
pop_val(I32)
@@ -232,8 +237,8 @@ Other instructions are checked in a similar manner.
232237
let rt = pop_ref()
233238
push_val(Ref(rt.heap, false))
234239
235-
   case (unreachable)
236-
      unreachable()
240+
case (unreachable)
241+
unreachable()
237242
238243
case (block t1*->t2*)
239244
pop_vals([t1*])
@@ -258,32 +263,32 @@ Other instructions are checked in a similar manner.
258263
push_ctrl(else, frame.start_types, frame.end_types)
259264
260265
case (br n)
261-
     error_if(ctrls.size() < n)
262-
      pop_vals(label_types(ctrls[n]))
263-
      unreachable()
266+
error_if(ctrls.size() < n)
267+
pop_vals(label_types(ctrls[n]))
268+
unreachable()
264269
265270
case (br_if n)
266-
     error_if(ctrls.size() < n)
271+
error_if(ctrls.size() < n)
267272
pop_val(I32)
268-
      pop_vals(label_types(ctrls[n]))
269-
      push_vals(label_types(ctrls[n]))
273+
pop_vals(label_types(ctrls[n]))
274+
push_vals(label_types(ctrls[n]))
270275
271-
   case (br_table n* m)
276+
case (br_table n* m)
272277
pop_val(I32)
273-
      error_if(ctrls.size() < m)
278+
error_if(ctrls.size() < m)
274279
let arity = label_types(ctrls[m]).size()
275-
      foreach (n in n*)
276-
        error_if(ctrls.size() < n)
277-
        error_if(label_types(ctrls[n]).size() =/= arity)
280+
foreach (n in n*)
281+
error_if(ctrls.size() < n)
282+
error_if(label_types(ctrls[n]).size() =/= arity)
278283
push_vals(pop_vals(label_types(ctrls[n])))
279-
      pop_vals(label_types(ctrls[m]))
280-
      unreachable()
284+
pop_vals(label_types(ctrls[m]))
285+
unreachable()
281286
282287
case (br_on_null n)
283-
     error_if(ctrls.size() < n)
288+
error_if(ctrls.size() < n)
284289
let rt = pop_ref()
285-
      pop_vals(label_types(ctrls[n]))
286-
      push_vals(label_types(ctrls[n]))
290+
pop_vals(label_types(ctrls[n]))
291+
push_vals(label_types(ctrls[n]))
287292
push_val(Ref(rt.heap, false))
288293
289294
case (call_ref)

document/core/appendix/changes.rst

+42-5
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,54 @@ Added instructions that modify ranges of memory or table entries [#proposal-reft
104104
* Active data and element segments boundaries are no longer checked at compile time but may trap instead
105105

106106

107+
.. index:: instructions, SIMD, value type, vector type
108+
109+
Vector instructions
110+
...................
111+
112+
Added vector type and instructions that manipulate multiple numeric values in parallel (also known as *SIMD*, single instruction multiple data) [#proposal-vectype]_
113+
114+
* New :ref:`value type <syntax-valtype>`: |V128|
115+
116+
* New :ref:`memory instructions <syntax-instr-memory>`: :math:`\K{v128.}\LOAD`, :math:`\K{v128.}\LOAD{}\!N\!\K{x}\!M\!\K{\_}\sx`, :math:`\K{v128.}\LOAD{}N\K{\_zero}`, :math:`\K{v128.}\LOAD{}N\K{\_splat}`, :math:`\K{v128.}\LOAD{}N\K{\_lane}`, :math:`\K{v128.}\STORE`, :math:`\K{v128.}\STORE{}N\K{\_lane}`
117+
118+
* New constant :ref:`vector instruction <syntax-instr-vec>`: :math:`\K{v128.}\VCONST`
119+
120+
* New unary :ref:`vector instructions <syntax-instr-vec>`: :math:`\K{v128.not}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.abs}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.neg}`, :math:`\K{i8x16.popcnt}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.abs}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.neg}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.sqrt}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.ceil}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.floor}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.trunc}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.nearest}`
121+
122+
* New binary :ref:`vector instructions <syntax-instr-vec>`: :math:`\K{v128.and}`, :math:`\K{v128.andnot}`, :math:`\K{v128.or}`, :math:`\K{v128.xor}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.add}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.sub}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.mul}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.add\_sat\_}\sx`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.sub\_sat\_}\sx`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.min\_}\sx`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.max\_}\sx`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.shl}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.shr\_}\sx`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.add}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.extmul\_}\half\K{\_i}\!N'\!\K{x}\!M'\!\K{\_}\sx`, :math:`\K{i16x8.q15mulr\_sat\_s}`, :math:`\K{i32x4.dot\_i16x8\_s}`, :math:`\K{i16x8.extadd\_pairwise\_i8x16\_}\sx`, :math:`\K{i32x4.extadd\_pairwise\_i16x8\_}\sx`, :math:`\K{i8x16.avgr\_u}`, :math:`\K{i16x8.avgr\_u}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.sub}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.mul}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.div}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.min}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.max}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.pmin}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.pmax}`
123+
124+
* New ternary :ref:`vector instruction <syntax-instr-vec>`: :math:`\K{v128.bitselect}`
125+
126+
* New test :ref:`vector instructions <syntax-instr-vec>`: :math:`\K{v128.any\_true}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.all\_true}`
127+
128+
* New relational :ref:`vector instructions <syntax-instr-vec>`: :math:`\K{i}\!N\!\K{x}\!M\!\K{.eq}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.ne}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.lt\_}\sx`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.gt\_}\sx`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.le\_}\sx`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.ge\_}\sx`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.eq}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.ne}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.lt}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.gt}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.le}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.ge}`
129+
130+
* New conversion :ref:`vector instructions <syntax-instr-vec>`::math:`\K{i32x4.trunc\_sat\_f32x4\_}\sx`, :math:`\K{i32x4.trunc\_sat\_f64x2\_}\sx\K{\_zero}`, :math:`\K{f32x4.convert\_i32x4\_}\sx`, :math:`\K{f32x4.demote\_f64x2\_zero}`, :math:`\K{f64x2.convert\_low\_i32x4\_}\sx`, :math:`\K{f64x2.promote\_low\_f32x4}`
131+
132+
* New lane access :ref:`vector instructions <syntax-instr-vec>`: :math:`\K{i}\!N\!\K{x}\!M\!\K{.extract\_lane\_}\sx^?`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.replace\_lane}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.extract\_lane}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.replace\_lane}`
133+
134+
* New lane splitting/combining :ref:`vector instructions <syntax-instr-vec>`: :math:`\K{i}\!N\!\K{x}\!M\!\K{.extend\_}\half\K{\_i}\!N'\!\K{x}\!M'\!\K{\_}\sx`, :math:`\K{i8x16.narrow\_i16x8\_}\sx`, :math:`\K{i16x8.narrow\_i32x4\_}\sx`
135+
136+
* New byte reordering :ref:`vector instructions <syntax-instr-vec>`: :math:`\K{i8x16.shuffle}`, :math:`\K{i8x16.swizzle}`
137+
138+
* New injection/projection :ref:`vector instructions <syntax-instr-vec>`: :math:`\K{i}\!N\!\K{x}\!M\!\K{.splat}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.splat}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.bitmask}`
139+
140+
107141
.. [#proposal-signext]
108-
https://github.com/WebAssembly/spec/tree/master/proposals/sign-extension-ops/
142+
https://github.com/WebAssembly/spec/tree/main/proposals/sign-extension-ops/
109143
110144
.. [#proposal-cvtsat]
111-
https://github.com/WebAssembly/spec/tree/master/proposals/nontrapping-float-to-int-conversion/
145+
https://github.com/WebAssembly/spec/tree/main/proposals/nontrapping-float-to-int-conversion/
112146
113147
.. [#proposal-multivalue]
114-
https://github.com/WebAssembly/spec/tree/master/proposals/multi-value/
148+
https://github.com/WebAssembly/spec/tree/main/proposals/multi-value/
115149
116150
.. [#proposal-reftype]
117-
https://github.com/WebAssembly/spec/tree/master/proposals/reference-types/
151+
https://github.com/WebAssembly/spec/tree/main/proposals/reference-types/
118152
119153
.. [#proposal-bulk]
120-
https://github.com/WebAssembly/spec/tree/master/proposals/bulk-memory-operations/
154+
https://github.com/WebAssembly/spec/tree/main/proposals/bulk-memory-operations/
155+
156+
.. [#proposal-vectype]
157+
https://github.com/WebAssembly/spec/tree/main/proposals/simd/

0 commit comments

Comments
 (0)