Skip to content

Commit 15ec7d1

Browse files
authored
Merge pull request #51 from dhil/wasmfx-merge
Merge with WebAssembly/spec
2 parents 217ad1f + b9fbcfa commit 15ec7d1

File tree

12 files changed

+231
-64
lines changed

12 files changed

+231
-64
lines changed

.github/workflows/ci-interpreter.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout repo
20-
uses: actions/checkout@v2
20+
uses: actions/checkout@v4
2121
- name: Setup OCaml
22-
uses: ocaml/setup-ocaml@v2
22+
uses: ocaml/setup-ocaml@v3
2323
with:
2424
ocaml-compiler: 4.14.x
2525
- name: Setup OCaml tools
2626
run: opam install --yes ocamlfind.1.9.5 js_of_ocaml.4.0.0 js_of_ocaml-ppx.4.0.0
2727
- name: Setup Node.js
28-
uses: actions/setup-node@v2
28+
uses: actions/setup-node@v4
2929
with:
3030
node-version: 20.x
3131
- name: Build interpreter

.github/workflows/ci-spec.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout repo
20-
uses: actions/checkout@v2
20+
uses: actions/checkout@v4
2121
with:
2222
submodules: "recursive"
2323
- name: Setup Node.js
24-
uses: actions/setup-node@v3
24+
uses: actions/setup-node@v4
2525
with:
2626
node-version: 16
2727
- name: Setup Bikeshed
@@ -44,7 +44,7 @@ jobs:
4444
runs-on: ubuntu-latest
4545
steps:
4646
- name: Checkout repo
47-
uses: actions/checkout@v2
47+
uses: actions/checkout@v4
4848
- name: Setup Bikeshed
4949
run: pip install bikeshed && bikeshed update
5050
- name: Run Bikeshed
@@ -59,7 +59,7 @@ jobs:
5959
runs-on: ubuntu-latest
6060
steps:
6161
- name: Checkout repo
62-
uses: actions/checkout@v2
62+
uses: actions/checkout@v4
6363
- name: Setup Bikeshed
6464
run: pip install bikeshed && bikeshed update
6565
- name: Run Bikeshed
@@ -128,7 +128,7 @@ jobs:
128128
runs-on: ubuntu-latest
129129
steps:
130130
- name: Checkout repo
131-
uses: actions/checkout@v2
131+
uses: actions/checkout@v4
132132
- name: Upload artifacts
133133
uses: actions/upload-artifact@v4
134134
with:
@@ -147,7 +147,7 @@ jobs:
147147
- build-spec-versions
148148
steps:
149149
- name: Checkout repo
150-
uses: actions/checkout@v2
150+
uses: actions/checkout@v4
151151
- name: Create output directory
152152
run: mkdir _output && cp document/index.html _output/index.html
153153
- name: Download core spec artifact
@@ -187,7 +187,7 @@ jobs:
187187
path: _output/versions
188188
- name: Publish to GitHub Pages
189189
if: github.ref == 'refs/heads/main'
190-
uses: peaceiris/actions-gh-pages@v3
190+
uses: peaceiris/actions-gh-pages@v4
191191
with:
192192
publish_dir: ./_output
193193
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/w3c-publish.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
name: Publish to W3C TR space
1+
name: Validate/Publish to W3C TR space
22

33
on:
44
push:
55
branches: [ main ]
66
paths: [ .github/**, document/** ]
7+
pull_request:
8+
paths: [ .github/**, document/** ]
79

810
# Allows you to run this workflow manually from the Actions tab, gh CLI tool,
911
# or REST API. THe w3c-status options correspond to the valid options for
@@ -23,30 +25,45 @@ on:
2325
- CRD
2426
- CR
2527

28+
env:
29+
YARN_ENABLE_IMMUTABLE_INSTALLS: false
30+
W3C_STATUS: ${{ github.event_name == 'workflow_dispatch' && inputs.w3c-status || 'WD' }}
31+
2632
jobs:
2733
publish-to-w3c-TR:
28-
if: github.repository == 'WebAssembly/spec'
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
spec: [core, js-api, web-api]
2938
runs-on: ubuntu-latest
3039
steps:
3140
- name: Checkout repo
32-
uses: actions/checkout@v2
41+
uses: actions/checkout@v4
3342
with:
3443
submodules: "recursive"
3544
- name: Setup Node.js
36-
uses: actions/setup-node@v3
45+
uses: actions/setup-node@v4
3746
with:
3847
node-version: 16
3948
- name: Setup Bikeshed
4049
run: pip install bikeshed && bikeshed update
4150
- name: Setup TexLive
51+
if: ${{ matrix.spec == 'core' }}
4252
run: sudo apt-get update -y && sudo apt-get install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
4353
- name: Setup Sphinx
54+
if: ${{ matrix.spec == 'core' }}
4455
run: pip install six && pip install sphinx==5.1.0
45-
- name: Publish all specs to their https://www.w3.org/TR/ URLs
46-
run: cd document && make -e WD-echidna-CI
56+
- name: Publish ${{ matrix.spec }} spec to its https://www.w3.org/TR/ URL
57+
if: env.W3C_ECHIDNA_TOKEN_CORE
58+
run: cd document && make -e -C ${{ matrix.spec }} WD-echidna-CI
4759
env:
48-
W3C_STATUS: ${{ github.event_name == 'push' && 'CRD' || inputs.w3c-status }}
4960
W3C_ECHIDNA_TOKEN_CORE: ${{ secrets.W3C_ECHIDNA_TOKEN_CORE }}
5061
W3C_ECHIDNA_TOKEN_JSAPI: ${{ secrets.W3C_ECHIDNA_TOKEN_JSAPI }}
5162
W3C_ECHIDNA_TOKEN_WEBAPI: ${{ secrets.W3C_ECHIDNA_TOKEN_WEBAPI }}
52-
YARN_ENABLE_IMMUTABLE_INSTALLS: false
63+
ECHIDNA_DRYRUN: ${{ !(github.event_name == 'push' && github.repository == 'WebAssembly/spec' && github.ref == 'refs/heads/main') }}
64+
- name: Validate ${{ matrix.spec }} spec with Echidna
65+
if: env.W3C_USERNAME
66+
run: cd document && make -e -C ${{ matrix.spec }} WD-echidna
67+
env:
68+
W3C_USERNAME: ${{ secrets.W3C_USERNAME }}
69+
W3C_PASSWORD: ${{ secrets.W3C_PASSWORD }}

document/core/Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ NAME = WebAssembly
1313
DECISION_URL = https://github.com/WebAssembly/meetings/blob/main/main/2024/WG-06-12.md
1414
TAR = tar
1515
DEADLINE = $(shell date -d "+30 days" +%Y-%m-%d 2>/dev/null || date -v +30d +%Y-%m-%d)
16+
ECHIDNA_DRYRUN = true
1617

1718
# Internal variables.
1819
PAPEROPT_a4 = -D latex_paper_size=a4
@@ -196,9 +197,11 @@ WD-echidna: WD-tar
196197
curl 'https://labs.w3.org/echidna/api/request' \
197198
--user '$(W3C_USERNAME):$(W3C_PASSWORD)' \
198199
-F "tar=@$(BUILDDIR)/WD.tar" \
199-
-F "decision=$(DECISION_URL)" | tee $(BUILDDIR)/WD-echidna-id.txt
200+
-F "decision=$(DECISION_URL)" \
201+
-F "dry-run=$(ECHIDNA_DRYRUN)" | tee $(BUILDDIR)/WD-echidna-id.txt
202+
python3 ../util/check-echidna-status.py $(BUILDDIR)
200203
@echo
201-
@echo "Published $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"
204+
@echo "Uploaded $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"
202205

203206
.PHONY: WD-echidna-CI
204207
WD-echidna-CI: WD-tar
@@ -210,9 +213,11 @@ WD-echidna-CI: WD-tar
210213
curl 'https://labs.w3.org/echidna/api/request' \
211214
-F "tar=@$(BUILDDIR)/WD.tar" \
212215
-F "token=$(W3C_ECHIDNA_TOKEN_CORE)" \
213-
-F "decision=$(DECISION_URL)" | tee $(BUILDDIR)/WD-echidna-id.txt
216+
-F "decision=$(DECISION_URL)" \
217+
-F "dry-run=$(ECHIDNA_DRYRUN)" | tee $(BUILDDIR)/WD-echidna-id.txt
218+
python3 ../util/check-echidna-status.py $(BUILDDIR)
214219
@echo
215-
@echo "Published $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"
220+
@echo "Uploaded $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"
216221

217222
.PHONY: diff
218223
diff: bikeshed

document/core/util/bikeshed_fixup.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212
def Main():
1313
data = open(sys.argv[1]).read()
1414

15-
# Make bikeshed happy
16-
# Apparently it can't handle empty line before DOCTYPE comment
17-
data = data.replace('\n<!DOCTYPE', '<!DOCTYPE')
18-
# Ensure newline before <pre>
19-
data = data.replace('<pre>', '\n<pre>')
15+
# Clean up the input for Bikeshed
2016

2117
# Don't add more than 3 levels to TOC.
2218
data = data.replace('<h5>', '<h5 class="no-toc">')
@@ -34,7 +30,7 @@ def Main():
3430
'Validation Algorithm',
3531
'Custom Sections',
3632
'Soundness',
37-
'Changes',
33+
'Change History',
3834
'Index of Types',
3935
'Index of Instructions',
4036
'Index of Semantic Rules']:
@@ -43,18 +39,6 @@ def Main():
4339
'<h3>A.' + str(number) + ' ' + section + '</h3>')
4440
number += 1
4541

46-
47-
# Drop spurious navigation.
48-
data = data.replace(
49-
"""
50-
<div class="related" role="navigation" aria-label="related navigation">
51-
<h3>Navigation</h3>
52-
<ul>
53-
<li class="nav-item nav-item-0"><a href="#">WebAssembly 1.1</a> &#187;</li>
54-
<li class="nav-item nav-item-this"><a href="">WebAssembly 1.1</a></li>
55-
</ul>
56-
</div> """, '')
57-
5842
# Use bikeshed biblio references for unicode and IEEE754
5943
data = data.replace(
6044
"""<a class="reference external" href="https://www.unicode.org/versions/latest/">Unicode</a>""",
@@ -88,6 +72,9 @@ def Main():
8872
r'\1',
8973
data, flags=re.DOTALL)
9074

75+
# Escape some latex sequences that Bikeshed interprets as macros
76+
data = data.replace(r' \\[1ex]', r' \&#x5c;\[1ex]')
77+
9178
sys.stdout.write(data)
9279

9380
Main()

document/js-api/Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ NAME = WebAssembly
66
DECISION_URL = https://github.com/WebAssembly/meetings/blob/main/main/2024/WG-06-12.md
77
TAR = tar
88
DEADLINE = $(shell date -d "+30 days" +%Y-%m-%d 2>/dev/null || date -v +30d +%Y-%m-%d)
9+
ECHIDNA_DRYRUN = true
910

1011
.PHONY: all
1112
all:
@@ -35,7 +36,6 @@ diff: all
3536
# macOS tar has no “--transform” option (only GNU tar does), so on macOS,
3637
# do “brew install tar” & run “make” like this: “TAR=gtar make -e WD-tar”
3738
WD-tar: all
38-
bikeshed spec --md-status=$(W3C_STATUS) --md-deadline=$(DEADLINE) index.bs $(BUILDDIR)/html/index.html
3939
$(TAR) -C $(BUILDDIR)/html --transform="s/index.html/Overview.html/" -cf $(BUILDDIR)/WD.tar index.html
4040
@echo "Built $(BUILDDIR)/WD.tar."
4141

@@ -50,7 +50,11 @@ WD-echidna: WD-tar
5050
curl 'https://labs.w3.org/echidna/api/request' \
5151
--user '$(W3C_USERNAME):$(W3C_PASSWORD)' \
5252
-F "tar=@$(BUILDDIR)/WD.tar" \
53-
-F "decision=$(DECISION_URL)" | tee $(BUILDDIR)/WD-echidna-id.txt
53+
-F "decision=$(DECISION_URL)" \
54+
-F "dry-run=$(ECHIDNA_DRYRUN)" | tee $(BUILDDIR)/WD-echidna-id.txt
55+
python3 ../util/check-echidna-status.py $(BUILDDIR)
56+
@echo
57+
@echo "Uploaded $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"
5458

5559
.PHONY: WD-echidna-CI
5660
WD-echidna-CI: WD-tar
@@ -62,6 +66,8 @@ WD-echidna-CI: WD-tar
6266
curl 'https://labs.w3.org/echidna/api/request' \
6367
-F "tar=@$(BUILDDIR)/WD.tar" \
6468
-F "token=$(W3C_ECHIDNA_TOKEN_JSAPI)" \
65-
-F "decision=$(DECISION_URL)" | tee $(BUILDDIR)/WD-echidna-id.txt
69+
-F "decision=$(DECISION_URL)" \
70+
-F "dry-run=$(ECHIDNA_DRYRUN)" | tee $(BUILDDIR)/WD-echidna-id.txt
71+
python3 ../util/check-echidna-status.py $(BUILDDIR)
6672
@echo
67-
@echo "Published $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"
73+
@echo "Uploaded $(W3C_STATUS). Check its status at https://labs.w3.org/echidna/api/status?id=`cat $(BUILDDIR)/WD-echidna-id.txt`"

document/js-api/index.bs

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ Date: now
2323
"title": "WebAssembly Core Specification",
2424
"publisher": "W3C WebAssembly Community Group",
2525
"status": "Draft"
26+
},
27+
"WASMWEB": {
28+
"href": "https://webassembly.github.io/spec/js-api/",
29+
"title": "WebAssembly Web API Specification",
30+
"publisher": "W3C WebAssembly Community Group",
31+
"status": "Draft"
2632
}
2733
}
2834
</pre>
@@ -63,10 +69,17 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMASCRIPT
6369
text: 𝔽; url: #𝔽
6470
text: ℤ; url: #ℤ
6571
text: SameValue; url: sec-samevalue
72+
text: Array; url: sec-array-exotic-objects
73+
text: BigInt; url: sec-ecmascript-language-types-bigint-type
6674
urlPrefix: https://webassembly.github.io/spec/core/; spec: WebAssembly; type: dfn
75+
text: embedding interface; url: appending/embedding.html
76+
text: scope; url: intro/introduction.html#scope
6777
url: valid/modules.html#valid-module
6878
text: valid
6979
text: WebAssembly module validation
80+
text: valid limits; url: valid/types.html#valid-limits
81+
text: valid memtype; url: valid/types.html#valid-memtype
82+
text: valid tabletype; url: valid/types.html#valid-tabletype
7083
text: module grammar; url: binary/modules.html#binary-module
7184
text: custom section; url: binary/modules.html#custom-section
7285
text: customsec; url: binary/modules.html#binary-customsec
@@ -122,9 +135,11 @@ urlPrefix: https://webassembly.github.io/spec/core/; spec: WebAssembly; type: df
122135
text: match_valtype; url: appendix/embedding.html#embed-match-valtype
123136
text: error; url: appendix/embedding.html#embed-error
124137
text: store; url: exec/runtime.html#syntax-store
138+
text: limits; url: syntax/types.html#syntax-limits
125139
text: table type; url: syntax/types.html#syntax-tabletype
126140
text: table address; url: exec/runtime.html#syntax-tableaddr
127141
text: function address; url: exec/runtime.html#syntax-funcaddr
142+
text: memory type; url: syntax/types.html#syntax-memtype
128143
text: memory address; url: exec/runtime.html#syntax-memaddr
129144
text: global address; url: exec/runtime.html#syntax-globaladdr
130145
text: tag address; url: exec/runtime.html#syntax-tagaddr
@@ -226,7 +241,14 @@ emu-const {
226241
}
227242
</style>
228243

229-
This API provides a way to access WebAssembly [[WEBASSEMBLY]] through a bridge to explicitly construct modules from JavaScript [[ECMASCRIPT]].
244+
<h2 id="intro">Introduction</h2>
245+
246+
By design, the [=scope=] of the WebAssembly core specification [[WEBASSEMBLY]] does not include a description of how WebAssembly programs interact with their surrounding execution environment.
247+
Instead it defines an abstract [=embedding interface=] between WebAssembly and its environment, (called the *embedder*).
248+
It is only through this interface that an embedder interacts with the semantics of WebAssembly, and the embedder implements the connection between its host environment and the embedding API.
249+
This document describes the embedding of WebAssembly into JavaScript [[ECMASCRIPT]] environments, including how WebAssembly modules can be constructed and instantiated, how imported and exported functions are called, how data is exchanged, and how errors are handled.
250+
When the JavaScript environment is itself embedded in a Web browser, the Web API spec [[WASMWEB]] describes additional behavior relevant to the Web environment.
251+
230252

231253
<h2 id="sample">Sample API Usage</h2>
232254

@@ -733,8 +755,8 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
733755
The <dfn constructor for="Memory">Memory(|descriptor|)</dfn> constructor, when invoked, performs the following steps:
734756
1. Let |initial| be |descriptor|["initial"].
735757
1. If |descriptor|["maximum"] [=map/exists=], let |maximum| be |descriptor|["maximum"]; otherwise, let |maximum| be empty.
736-
1. If |maximum| is not empty and |maximum| &lt; |initial|, throw a {{RangeError}} exception.
737-
1. Let |memtype| be { min |initial|, max |maximum| }.
758+
1. Let |memtype| be the [=memory type=] { <b>[=limits|min=]</b> |initial|, <b>[=limits|max=]</b> |maximum| }.
759+
1. If |memtype| is not [=valid memtype|valid=], throw a {{RangeError}} exception.
738760
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
739761
1. Let (|store|, |memaddr|) be [=mem_alloc=](|store|, |memtype|). If allocation fails, throw a {{RangeError}} exception.
740762
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
@@ -894,15 +916,17 @@ Each {{Table}} object has a \[[Table]] internal slot, which is a [=table address
894916
1. Throw a {{TypeError}} exception.
895917
1. Let |initial| be |descriptor|["initial"].
896918
1. If |descriptor|["maximum"] [=map/exists=], let |maximum| be |descriptor|["maximum"]; otherwise, let |maximum| be empty.
897-
1. If |maximum| is not empty and |maximum| &lt; |initial|, throw a {{RangeError}} exception.
919+
1. Let |type| be the [=table type=] { <b>[=limits|min=]</b> |initial|, <b>[=limits|max=]</b> |maximum| } |elementType|.
920+
1. If |type| is not [=valid tabletype|valid=], throw a {{RangeError}} exception.
921+
922+
Note: Because tables may have up to 2<sup>32</sup> - 1 elements in validation, the checks for [=limits|min=] ≤ 2<sup>32</sup> - 1 and [=limits|max=] ≤ 2<sup>32</sup> - 1 in [=valid limits|limits validation=] cannot fail.
898923
1. If |value| is missing,
899924
1. Let |ref| be [=DefaultValue=](|elementType|).
900925
1. Assert: |ref| is not [=error=].
901926
1. Otherwise,
902927
1. Let |ref| be [=?=] [=ToWebAssemblyValue=](|value|, |elementType|).
903-
1. Let |type| be the [=table type=] {[=table type|min=] |initial|, [=table type|max=] |maximum|} |elementType|.
904928
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
905-
1. Let (|store|, |tableaddr|) be [=table_alloc=](|store|, |type|, |ref|). <!-- TODO(littledan): Report allocation failure https://github.com/WebAssembly/spec/issues/584 -->
929+
1. Let (|store|, |tableaddr|) be [=table_alloc=](|store|, |type|, |ref|). If allocation fails, throw a {{RangeError}} exception.
906930
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
907931
1. [=initialize a table object|Initialize=] **this** from |tableaddr|.
908932
</div>
@@ -1736,3 +1760,22 @@ In practice, an implementation may run out of resources for valid modules below
17361760
<p><em>This section is non-normative.</em></p>
17371761

17381762
This document defines a host environment for WebAssembly. It enables a WebAssembly instance to [=import=] JavaScript objects and functions from an [=read the imports|import object=], but otherwise provides no access to the embedding environment. Thus a WebAssembly instance is bound to the same constraints as JavaScript.
1763+
1764+
<h2 id="change-history">Change History</h2>
1765+
1766+
<p><em>This section is non-normative.</em></p>
1767+
1768+
<p>Since the original release 1.0 of the WebAssembly specification, a number of proposals for extensions have been integrated.
1769+
The following sections provide an overview of what has changed.</p>
1770+
1771+
<h3 id="release-20">Release 2.0</h3>
1772+
1773+
<h4 id="changes-multivalue" class="no-toc heading settled">Multiple Values</h4>
1774+
Multiple values can be returned from WebAssembly functions into JavaScript as an [=Array=] object.
1775+
1776+
<h4 id="changes-bigint" class="no-toc heading settled">BigInt Integration</h4>
1777+
WebAssembly [=i64=] values can be passed to and from JavaScript (via imported or exported globals, table get or set operations, function return values or arguments) as [=BigInt=] objects.
1778+
1779+
<h4 id="changes-reftypes" class="no-toc heading settled">Reference types</h4>
1780+
JavaScript values can be passed to and from WebAssembly (via imported or exported globals, table set or get operations, and function arguments or return values) as [=externref=] values.
1781+
Multiple tables can be exported and imported to and from JavaScript.

0 commit comments

Comments
 (0)