Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into merge-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
ngzhian committed Oct 21, 2021
2 parents a3e4b05 + ee4a6c4 commit 5ef6f0d
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 51 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
name: core-api-rendered
path: _output/core
- name: Publish HTML to GitHub Pages
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
publish_dir: ./_output
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on:
push:
branches:
- 'main'

jobs:
mirror_job:
runs-on: ubuntu-latest
name: Mirror main branch to master branch
steps:
- name: Mirror action step
id: mirror
uses: google/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
source: 'main'
dest: 'master'
2 changes: 1 addition & 1 deletion Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
Interested in participating? Please follow
[the same contributing guidelines as the design repository][].

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

Also, please be sure to read [the README.md](README.md) for this repository.
52 changes: 25 additions & 27 deletions document/core/appendix/algorithm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,13 @@ However, these variables are not manipulated directly by the main checking funct
func pop_val(expect : val_type | Unknown) : val_type | Unknown =
let actual = pop_val()
if (actual = Unknown) return expect
if (expect = Unknown) return actual
error_if(actual =/= expect)
error_if(actual =/= expect && actual =/= Unknown && expect =/= Unknown)
return actual
func push_vals(types : list(val_type)) = foreach (t in types) push_val(t)
func pop_vals(types : list(val_type)) : list(val_type) =
var popped := []
foreach (t in reverse(types)) popped.append(pop_val(t))
foreach (t in reverse(types)) popped.prepend(pop_val(t))
return popped
Pushing an operand value simply pushes the respective type to the value stack.
Expand All @@ -109,24 +107,24 @@ The control stack is likewise manipulated through auxiliary functions:
.. code-block:: pseudo
func push_ctrl(opcode : opcode, in : list(val_type), out : list(val_type)) =
 let frame = ctrl_frame(opcode, in, out, vals.size(), false)
  ctrls.push(frame)
let frame = ctrl_frame(opcode, in, out, vals.size(), false)
ctrls.push(frame)
push_vals(in)
func pop_ctrl() : ctrl_frame =
 error_if(ctrls.is_empty())
 let frame = ctrls[0]
  pop_vals(frame.end_types)
  error_if(vals.size() =/= frame.height)
error_if(ctrls.is_empty())
let frame = ctrls[0]
pop_vals(frame.end_types)
error_if(vals.size() =/= frame.height)
ctrls.pop()
  return frame
return frame
func label_types(frame : ctrl_frame) : list(val_types) =
return (if frame.opcode == loop then frame.start_types else frame.end_types)
func unreachable() =
  vals.resize(ctrls[0].height)
  ctrls[0].unreachable := true
vals.resize(ctrls[0].height)
ctrls[0].unreachable := true
Pushing a control frame takes the types of the label and result values.
It allocates a new frame record recording them along with the current height of the operand stack and marks the block as reachable.
Expand Down Expand Up @@ -184,8 +182,8 @@ Other instructions are checked in a similar manner.
pop_val(t)
push_val(t)
   case (unreachable)
      unreachable()
case (unreachable)
unreachable()
case (block t1*->t2*)
pop_vals([t1*])
Expand All @@ -210,26 +208,26 @@ Other instructions are checked in a similar manner.
push_ctrl(else, frame.start_types, frame.end_types)
case (br n)
     error_if(ctrls.size() < n)
      pop_vals(label_types(ctrls[n]))
      unreachable()
error_if(ctrls.size() < n)
pop_vals(label_types(ctrls[n]))
unreachable()
case (br_if n)
     error_if(ctrls.size() < n)
error_if(ctrls.size() < n)
pop_val(I32)
      pop_vals(label_types(ctrls[n]))
      push_vals(label_types(ctrls[n]))
pop_vals(label_types(ctrls[n]))
push_vals(label_types(ctrls[n]))
   case (br_table n* m)
case (br_table n* m)
pop_val(I32)
      error_if(ctrls.size() < m)
error_if(ctrls.size() < m)
let arity = label_types(ctrls[m]).size()
      foreach (n in n*)
        error_if(ctrls.size() < n)
        error_if(label_types(ctrls[n]).size() =/= arity)
foreach (n in n*)
error_if(ctrls.size() < n)
error_if(label_types(ctrls[n]).size() =/= arity)
push_vals(pop_vals(label_types(ctrls[n])))
pop_vals(label_types(ctrls[m]))
      unreachable()
unreachable()
.. note::
Expand Down
2 changes: 0 additions & 2 deletions document/core/valid/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1414,8 +1414,6 @@ Control Instructions

* The label :math:`C.\CLABELS[l_N]` must be defined in the context.

* Let :math:`[t^\ast]` be the :ref:`result type <syntax-resulttype>` :math:`C.\CLABELS[l_N]`.

* For all :math:`l_i` in :math:`l^\ast`,
the label :math:`C.\CLABELS[l_i]` must be defined in the context.

Expand Down
2 changes: 1 addition & 1 deletion document/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ incremental_deploy() {
0) echo No changes to files in $deploy_directory. Skipping commit.;;
1) commit_and_push;;
*)
echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to master, use: git symbolic-ref HEAD refs/heads/master && git reset --mixed >&2
echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to main, use: git symbolic-ref HEAD refs/heads/main && git reset --mixed >&2
return $diff
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions interpreter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ WebAssemblyText.decode(binary)

## S-Expression Syntax

The implementation consumes a WebAssembly AST given in S-expression syntax. Here is an overview of the grammar of types, expressions, functions, and modules, mirroring what's described in the [design doc](https://github.com/WebAssembly/design/blob/master/Semantics.md).
The implementation consumes a WebAssembly AST given in S-expression syntax. Here is an overview of the grammar of types, expressions, functions, and modules, mirroring what's described in the [design doc](https://github.com/WebAssembly/design/blob/main/Semantics.md).

Note: The grammar is shown here for convenience, the definite source is the [specification of the text format](https://webassembly.github.io/spec/core/text/).
```
Expand Down Expand Up @@ -509,7 +509,7 @@ Moreover, float values are required to be precise, that is, they may not contain

## Abstract Syntax

The abstract WebAssembly syntax, as described above and in the [design doc](https://github.com/WebAssembly/design/blob/master/Semantics.md), is defined in [ast.ml](syntax/ast.ml).
The abstract WebAssembly syntax, as described above and in the [design doc](https://github.com/WebAssembly/design/blob/main/Semantics.md), is defined in [ast.ml](syntax/ast.ml).

However, to simplify the implementation, this AST representation represents some of the inner structure of the operators more explicitly. The mapping from the operators as given in the design doc to their structured form is defined in [operators.ml](syntax/operators.ml).

Expand Down
2 changes: 1 addition & 1 deletion interpreter/binary/decode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ let module_ s =
iterate custom_section s;
let datas = data_section s in
iterate custom_section s;
require (pos s = len s) s (len s) "junk after last section";
require (pos s = len s) s (len s) "unexpected content after last section";
require (List.length func_types = List.length func_bodies)
s (len s) "function and code section have inconsistent lengths";
require (data_count = None || data_count = Some (Lib.List32.length datas))
Expand Down
2 changes: 1 addition & 1 deletion proposals/multi-value/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- can easily be lifted by generalising to value* -> value*

* Generalised semantics is well-understood
- https://github.com/WebAssembly/spec/tree/master/papers/pldi2017.pdf
- https://github.com/WebAssembly/spec/tree/main/papers/pldi2017.pdf

* Semi-complete implementation of multiple results in V8

Expand Down
4 changes: 2 additions & 2 deletions proposals/nontrapping-float-to-int-conversion/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ https://github.com/WebAssembly/meetings/pull/3

and

https://github.com/WebAssembly/meetings/blob/master/2017/CG-05.md#non-trapping-float-to-int
https://github.com/WebAssembly/meetings/blob/main/2017/CG-05.md#non-trapping-float-to-int

which made decisions about which semantics to choose, and which encoding strategy.

Expand All @@ -43,7 +43,7 @@ https://github.com/WebAssembly/design/pull/1089
At the CG-07-06 meeting it was decided that a full spec repo fork should be
created to follow the new process for new features:

https://github.com/WebAssembly/meetings/blob/master/2017/CG-07-06.md#float-to-int-conversion
https://github.com/WebAssembly/meetings/blob/main/2017/CG-07-06.md#float-to-int-conversion

This led to the creation of the present repo:

Expand Down
4 changes: 2 additions & 2 deletions proposals/reference-types/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ TODO: more text, motivation, explanation

Motivation:

* Easier and more efficient interop with host environment (see e.g. the [Interface Types proposal](https://github.com/WebAssembly/interface-types/blob/master/proposals/interface-types/Explainer.md))
* Easier and more efficient interop with host environment (see e.g. the [Interface Types proposal](https://github.com/WebAssembly/interface-types/blob/main/proposals/interface-types/Explainer.md))
- allow host references to be represented directly by type `externref` (see [here](https://github.com/WebAssembly/interface-types/issues/9))
- without having to go through tables, allocating slots, and maintaining index bijections at the boundaries

Expand All @@ -19,7 +19,7 @@ by repurposing tables as a general memory for opaque data types
* Set the stage for later additions:

- Typed function references (see [below](#typed-function-references))
- Exception references (see the [exception handling proposal](https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md) and [here](https://github.com/WebAssembly/interface-types/issues/10))
- Exception references (see the [exception handling proposal](https://github.com/WebAssembly/exception-handling/blob/main/proposals/Exceptions.md) and [here](https://github.com/WebAssembly/interface-types/issues/10))
- A smoother transition path to GC (see the [GC proposal](https://github.com/WebAssembly/gc/blob/master/proposals/gc/Overview.md))

Get the most important parts soon!
Expand Down
2 changes: 1 addition & 1 deletion proposals/sign-extension-ops/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ instr ::= ...
| 0xC4 => i64.extend32_s
```

[future sext]: https://github.com/WebAssembly/design/blob/master/FutureFeatures.md#additional-integer-operators
[future sext]: https://github.com/WebAssembly/design/blob/main/FutureFeatures.md#additional-integer-operators
[instruction syntax]: https://webassembly.github.io/spec/syntax/instructions.html
[instruction binary format]: https://webassembly.github.io/spec/binary/instructions.html
[spec]: https://webassembly.github.io/sign-extension-ops/
2 changes: 1 addition & 1 deletion test/Todo.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a rough list of "tests to write". Everything here should either be
specified in [Semantics.md](https://github.com/WebAssembly/design/blob/master/Semantics.md),
specified in [Semantics.md](https://github.com/WebAssembly/design/blob/main/Semantics.md),
have a link to an open issue/PR, or be obvious. Comments/corrections/additions
welcome.

Expand Down
4 changes: 2 additions & 2 deletions test/core/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This directory contains tests for the core WebAssembly semantics, as described in [Semantics.md](https://github.com/WebAssembly/design/blob/master/Semantics.md) and specified by the [spec interpreter](https://github.com/WebAssembly/spec/blob/master/interpreter).
This directory contains tests for the core WebAssembly semantics, as described in [Semantics.md](https://github.com/WebAssembly/design/blob/main/Semantics.md) and specified by the [spec interpreter](https://github.com/WebAssembly/spec/blob/main/interpreter).

Tests are written in the [S-Expression script format](https://github.com/WebAssembly/spec/blob/master/interpreter/README.md#s-expression-syntax) defined by the interpreter.
Tests are written in the [S-Expression script format](https://github.com/WebAssembly/spec/blob/main/interpreter/README.md#s-expression-syntax) defined by the interpreter.

The test suite can be run with the spec interpreter as follows:
```
Expand Down
10 changes: 5 additions & 5 deletions test/core/binary.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\05\03\01" ;; table section with one entry
"\04\03\01" ;; table section with one entry
"\70" ;; anyfunc
"\02" ;; malformed table limits flag
)
Expand All @@ -1415,7 +1415,7 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\05\04\01" ;; table section with one entry
"\04\04\01" ;; table section with one entry
"\70" ;; anyfunc
"\02" ;; malformed table limits flag
"\00" ;; dummy byte
Expand All @@ -1425,12 +1425,12 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\05\06\01" ;; table section with one entry
"\04\06\01" ;; table section with one entry
"\70" ;; anyfunc
"\81\00" ;; malformed table limits flag as LEB128
"\00\00" ;; dummy bytes
)
"integer too large"
"integer representation too long"
)

;; Memory count can be zero
Expand Down Expand Up @@ -1760,5 +1760,5 @@
"\02\00"
"\0b" ;; end
)
"junk after last section"
"unexpected content after last section"
)
Binary file modified test/core/comments.wast
Binary file not shown.
10 changes: 10 additions & 0 deletions test/core/f32.wast
Original file line number Diff line number Diff line change
Expand Up @@ -2531,3 +2531,13 @@
(assert_invalid (module (func (result f32) (f32.nearest (i64.const 0)))) "type mismatch")
(assert_invalid (module (func (result f32) (f32.sqrt (i64.const 0)))) "type mismatch")
(assert_invalid (module (func (result f32) (f32.trunc (i64.const 0)))) "type mismatch")

;; These float literal patterns are only allowed in scripts, not in text format.
(assert_malformed
(module quote "(func (result f32) (f32.const nan:arithmetic))")
"unexpected token"
)
(assert_malformed
(module quote "(func (result f32) (f32.const nan:canonical))")
"unexpected token"
)
10 changes: 10 additions & 0 deletions test/core/f64.wast
Original file line number Diff line number Diff line change
Expand Up @@ -2531,3 +2531,13 @@
(assert_invalid (module (func (result f64) (f64.nearest (i64.const 0)))) "type mismatch")
(assert_invalid (module (func (result f64) (f64.sqrt (i64.const 0)))) "type mismatch")
(assert_invalid (module (func (result f64) (f64.trunc (i64.const 0)))) "type mismatch")

;; These float literal patterns are only allowed in scripts, not in text format.
(assert_malformed
(module quote "(func (result f64) (f64.const nan:arithmetic))")
"unexpected token"
)
(assert_malformed
(module quote "(func (result f64) (f64.const nan:canonical))")
"unexpected token"
)
9 changes: 9 additions & 0 deletions test/core/i32.wast
Original file line number Diff line number Diff line change
Expand Up @@ -974,3 +974,12 @@
(assert_invalid (module (func (result i32) (i32.lt_s (i64.const 0) (f32.const 0)))) "type mismatch")
(assert_invalid (module (func (result i32) (i32.lt_u (i64.const 0) (f32.const 0)))) "type mismatch")
(assert_invalid (module (func (result i32) (i32.ne (i64.const 0) (f32.const 0)))) "type mismatch")

(assert_malformed
(module quote "(func (result i32) (i32.const nan:arithmetic))")
"unexpected token"
)
(assert_malformed
(module quote "(func (result i32) (i32.const nan:canonical))")
"unexpected token"
)
9 changes: 9 additions & 0 deletions test/core/i64.wast
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,12 @@
(assert_invalid (module (func (result i64) (i64.lt_s (i32.const 0) (f32.const 0)))) "type mismatch")
(assert_invalid (module (func (result i64) (i64.lt_u (i32.const 0) (f32.const 0)))) "type mismatch")
(assert_invalid (module (func (result i64) (i64.ne (i32.const 0) (f32.const 0)))) "type mismatch")

(assert_malformed
(module quote "(func (result i64) (i64.const nan:arithmetic))")
"unexpected token"
)
(assert_malformed
(module quote "(func (result i64) (i64.const nan:canonical))")
"unexpected token"
)

0 comments on commit 5ef6f0d

Please sign in to comment.