This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspec-wasmfx.patch
12739 lines (11915 loc) · 482 KB
/
spec-wasmfx.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/.github/workflows/ci-interpreter.yml b/.github/workflows/ci-interpreter.yml
deleted file mode 100644
index 8f7b02c0..00000000
--- a/.github/workflows/ci-interpreter.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-name: CI for interpreter & tests
-
-on:
- push:
- branches: [ main ]
- paths: [ interpreter/**, test/** ]
-
- pull_request:
- branches: [ main ]
- paths: [ interpreter/**, test/** ]
-
- # Allows you to run this workflow manually from the Actions tab
- workflow_dispatch:
-
-jobs:
- interpreter:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repo
- uses: actions/checkout@v2
- - name: Setup OCaml
- uses: ocaml/setup-ocaml@v2
- with:
- ocaml-compiler: 4.14.x
- - name: Setup OCaml tools
- run: opam install --yes ocamlbuild.0.14.0 ocamlfind.1.9.5 js_of_ocaml.4.0.0 js_of_ocaml-ppx.4.0.0
- - name: Setup Node.js
- uses: actions/setup-node@v2
- with:
- node-version: 19.x
- - name: Build interpreter
- run: cd interpreter && opam exec make
- - name: Run tests
- # TODO: disable node.js run until it fully implements proposal
- # run: cd interpreter && opam exec make JS=node ci
- run: cd interpreter && opam exec make ci
diff --git a/.github/workflows/ci-spec.yml b/.github/workflows/ci-spec.yml
deleted file mode 100644
index 7610b33b..00000000
--- a/.github/workflows/ci-spec.yml
+++ /dev/null
@@ -1,101 +0,0 @@
-name: CI for specs
-
-on:
- push:
- branches: [ main ]
- paths: [ document/** ]
-
- pull_request:
- branches: [ main ]
- paths: [ document/** ]
-
- # Allows you to run this workflow manually from the Actions tab
- workflow_dispatch:
-
-jobs:
- build-core-spec:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repo
- uses: actions/checkout@v2
- with:
- submodules: "recursive"
- - name: Setup Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 16
- - name: Setup Bikeshed
- run: pip install bikeshed && bikeshed update
- - name: Setup TexLive
- run: sudo apt-get update -y && sudo apt-get install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
- - name: Setup Sphinx
- run: pip install six && pip install sphinx==5.1.0
- - name: Build main spec
- run: cd document/core && make main
- - name: Run Bikeshed
- run: cd document/core && make bikeshed
- - name: Upload artifact
- uses: actions/upload-artifact@v2
- with:
- name: core-rendered
- path: document/core/_build/html
-
- build-js-api-spec:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repo
- uses: actions/checkout@v2
- - name: Setup Bikeshed
- run: pip install bikeshed && bikeshed update
- - name: Run Bikeshed
- run: bikeshed spec "document/js-api/index.bs" "document/js-api/index.html"
- - name: Upload artifact
- uses: actions/upload-artifact@v2
- with:
- name: js-api-rendered
- path: document/js-api/index.html
-
- build-web-api-spec:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repo
- uses: actions/checkout@v2
- - name: Setup Bikeshed
- run: pip install bikeshed && bikeshed update
- - name: Run Bikeshed
- run: bikeshed spec "document/web-api/index.bs" "document/web-api/index.html"
- - name: Upload artifact
- uses: actions/upload-artifact@v2
- with:
- name: web-api-rendered
- path: document/web-api/index.html
-
- publish-spec:
- runs-on: ubuntu-latest
- needs: [build-core-spec, build-js-api-spec, build-web-api-spec]
- steps:
- - name: Checkout repo
- uses: actions/checkout@v2
- - name: Create output directory
- run: mkdir _output && cp document/index.html _output/index.html
- - name: Download core spec artifact
- uses: actions/download-artifact@v2
- with:
- name: core-rendered
- path: _output/core
- - name: Download JS API spec artifact
- uses: actions/download-artifact@v2
- with:
- name: js-api-rendered
- path: _output/js-api
- - name: Download Web API spec artifact
- uses: actions/download-artifact@v2
- with:
- name: web-api-rendered
- path: _output/web-api
- - name: Publish to GitHub Pages
- if: github.ref == 'refs/heads/main'
- uses: peaceiris/actions-gh-pages@v3
- with:
- publish_dir: ./_output
- github_token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 00000000..e20e3db4
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,105 @@
+name: CI
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+jobs:
+ ref-interpreter:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup OCaml
+ uses: ocaml/setup-ocaml@v2
+ with:
+ ocaml-compiler: 4.13.x
+ - run: opam install --yes ocamlbuild.0.14.0
+ - name: Setup Node.js
+ uses: actions/setup-node@v1
+ with:
+ node-version: 19.x
+ # TODO: disable node.js run until it fully implements proposal
+ # - run: cd interpreter && opam exec make JS=node all
+ - run: cd interpreter && opam exec make all
+
+ ref-interpreter-js-library:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup OCaml
+ uses: ocaml/setup-ocaml@v2
+ with:
+ ocaml-compiler: 4.13.x
+ - run: opam install --yes ocamlbuild.0.14.0 ocamlfind.1.9.5 js_of_ocaml.4.0.0 js_of_ocaml-ppx.4.0.0
+ - run: cd interpreter && opam exec make wast.js
+
+ build-js-api-spec:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - run: pip install bikeshed && bikeshed update
+ - run: bikeshed spec "document/js-api/index.bs" "document/js-api/index.html"
+ - uses: actions/upload-artifact@v2
+ with:
+ name: js-api-rendered
+ path: document/js-api/index.html
+
+ build-web-api-spec:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - run: pip install bikeshed && bikeshed update
+ - run: bikeshed spec "document/web-api/index.bs" "document/web-api/index.html"
+ - uses: actions/upload-artifact@v2
+ with:
+ name: web-api-rendered
+ path: document/web-api/index.html
+
+ build-core-spec:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ submodules: "recursive"
+ - uses: actions/setup-node@v3
+ with:
+ node-version: 16
+ - run: pip install bikeshed && bikeshed update
+ - run: pip install six
+ - run: sudo apt-get update -y && sudo apt-get install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
+ - run: pip install sphinx==5.1.0
+ - run: cd document/core && make all
+ - uses: actions/upload-artifact@v2
+ with:
+ name: core-api-rendered
+ path: document/core/_build/html
+
+ publish-spec:
+ runs-on: ubuntu-latest
+ needs: [build-core-spec, build-js-api-spec, build-web-api-spec]
+ steps:
+ - uses: actions/checkout@v2
+ - run: mkdir _output && cp document/index.html _output/index.html
+ - uses: actions/download-artifact@v2
+ with:
+ name: js-api-rendered
+ path: _output/js-api
+ - uses: actions/download-artifact@v2
+ with:
+ name: web-api-rendered
+ path: _output/web-api
+ - uses: actions/download-artifact@v2
+ with:
+ name: core-api-rendered
+ path: _output/core
+ - name: Publish HTML to GitHub Pages
+ if: github.ref == 'refs/heads/main'
+ uses: peaceiris/actions-gh-pages@v3
+ with:
+ publish_dir: ./_output
+ github_token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/mirror-to-master.yml b/.github/workflows/mirror.yml
similarity index 81%
rename from .github/workflows/mirror-to-master.yml
rename to .github/workflows/mirror.yml
index 7849af75..5c470757 100644
--- a/.github/workflows/mirror-to-master.yml
+++ b/.github/workflows/mirror.yml
@@ -1,5 +1,3 @@
-name: Mirror main branch to master branch
-
on:
push:
branches:
@@ -10,7 +8,8 @@ jobs:
runs-on: ubuntu-latest
name: Mirror main branch to master branch
steps:
- - name: Mirror branch
+ - name: Mirror action step
+ id: mirror
uses: google/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/README.md b/README.md
index b204e475..d9d4412d 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,20 @@
-[![CI for specs](https://github.com/WebAssembly/function-references/actions/workflows/ci-spec.yml/badge.svg)](https://github.com/WebAssembly/function-references/actions/workflows/ci-spec.yml)
-[![CI for interpreter & tests](https://github.com/WebAssembly/function-references/actions/workflows/ci-interpreter.yml/badge.svg)](https://github.com/WebAssembly/function-references/actions/workflows/ci-interpreter.yml)
+# Typed Continuations Proposal for WebAssembly
-# Function Reference Types Proposal for WebAssembly
+This repository is a clone of
+[github.com/WebAssembly/spec/](https://github.com/WebAssembly/spec/).
+It is meant for discussion, prototype specification and implementation
+of a proposal to add support for different patterns of non-local
+control flow to WebAssembly.
-This repository is a clone of [github.com/WebAssembly/spec/](https://github.com/WebAssembly/spec/).
-It is meant for discussion, prototype specification and implementation of a proposal to add support for basic function reference types to WebAssembly.
+The proposal is fully implemented as part of the reference interpreter.
-* See the [overview](proposals/function-references/Overview.md) for a summary of the proposal.
+* See the [explainer](proposals/continuations/Explainer.md) for a high-level summary of the proposal.
-* See the [modified spec](https://webassembly.github.io/function-references/core) for details.
+* See the [overview](proposals/continuations/Overview.md) for a more formal description of the proposal.
-The repository is now based on the [bulk operations proposal](proposals/bulk-memory-operations/Overview.md) and includes all respective changes.
+* See the [examples](proposals/continuations/examples) for Wasm code for implementing various different features including lightweight threads, actors, and async/await.
-Original README from upstream repository follows...
+Original `README` from upstream repository follows.
# spec
diff --git a/document/core/.gitignore b/document/core/.gitignore
index b932ec28..d21e55e3 100644
--- a/document/core/.gitignore
+++ b/document/core/.gitignore
@@ -1,3 +1,4 @@
_build
_static
document/*.pyc
+appendix/index-instructions.rst
diff --git a/document/core/Makefile b/document/core/Makefile
index 8a3650ec..d8b357c7 100644
--- a/document/core/Makefile
+++ b/document/core/Makefile
@@ -89,14 +89,12 @@ bikeshed-keep:
echo Downloaded Bikeshed.
-GENERATED = appendix/index-instructions.rst
-.INTERMEDIATE: $(GENERATED)
-
-%.rst: %.py
- (cd `dirname $@`; ./`basename $^`)
+.PHONY: index
+index:
+ (cd appendix; ./index-instructions.py)
.PHONY: pdf
-pdf: $(GENERATED) latexpdf
+pdf: index latexpdf
mkdir -p $(BUILDDIR)/html/$(DOWNLOADDIR)
ln -f $(BUILDDIR)/latex/$(NAME).pdf $(BUILDDIR)/html/$(DOWNLOADDIR)/$(NAME).pdf
@@ -105,10 +103,10 @@ pdf: $(GENERATED) latexpdf
clean:
rm -rf $(BUILDDIR)
rm -rf $(STATICDIR)
- rm -f $(GENERATED)
+ rm -f appendix/index-instructions.rst
.PHONY: html
-html: $(GENERATED)
+html: index
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
for file in `ls $(BUILDDIR)/html/*.html`; \
do \
@@ -124,34 +122,28 @@ html: $(GENERATED)
@echo "Build finished. The HTML pages are in `pwd`/$(BUILDDIR)/html/."
.PHONY: dirhtml
-dirhtml: $(GENERATED)
+dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
.PHONY: singlehtml
-singlehtml: $(GENERATED)
+singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
.PHONY: bikeshed
-bikeshed: $(GENERATED)
+bikeshed:
$(SPHINXBUILD) -b singlehtml -c util/bikeshed \
$(ALLSPHINXOPTS) $(BUILDDIR)/bikeshed_singlehtml
- python3 util/bikeshed_fixup.py $(BUILDDIR)/bikeshed_singlehtml/index.html \
+ python util/bikeshed_fixup.py $(BUILDDIR)/bikeshed_singlehtml/index.html \
>$(BUILDDIR)/bikeshed_singlehtml/index_fixed.html
- @echo ==== Showing contents of _build/bikeshed_singlehtml/index_fixed.html ====
- @head -n10 _build/bikeshed_singlehtml/index_fixed.html
- @echo ... skipping $$(expr `cat _build/bikeshed_singlehtml/index_fixed.html | wc -l` - 20) lines ...
- @tail -n10 _build/bikeshed_singlehtml/index_fixed.html
- @echo
- @echo =========================================================================
mkdir -p $(BUILDDIR)/bikeshed_mathjax/
bikeshed spec index.bs $(BUILDDIR)/bikeshed_mathjax/index.html
mkdir -p $(BUILDDIR)/html/bikeshed/
(cd util/katex/ && yarn && yarn build && npm install --only=prod)
- python3 util/mathjax2katex.py $(BUILDDIR)/bikeshed_mathjax/index.html \
+ python util/mathjax2katex.py $(BUILDDIR)/bikeshed_mathjax/index.html \
>$(BUILDDIR)/html/bikeshed/index.html
mkdir -p $(BUILDDIR)/html/bikeshed/katex/dist/
cp -r util/katex/dist/* $(BUILDDIR)/html/bikeshed/katex/dist/
@@ -268,7 +260,7 @@ latex:
"(use \`make latexpdf' here to do that automatically)."
.PHONY: latexpdf
-latexpdf: $(GENERATED)
+latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex LATEXMKOPTS=" </dev/null" all-pdf >$(BUILDDIR)/latex/LOG 2>&1 || cat $(BUILDDIR)/latex/LOG
diff --git a/document/core/appendix/embedding.rst b/document/core/appendix/embedding.rst
index c94f8753..dda85673 100644
--- a/document/core/appendix/embedding.rst
+++ b/document/core/appendix/embedding.rst
@@ -167,7 +167,7 @@ Modules
:math:`\F{module\_imports}(\module) : (\name, \name, \externtype)^\ast`
.......................................................................
-1. Pre-condition: :math:`\module` is :ref:`valid <valid-module>` with the external import types :math:`\externtype^\ast` and external export types :math:`{\externtype'}^\ast`.
+1. Pre-condition: :math:`\module` is :ref:`valid <valid-module>` with the :ref:`dynamic <syntax-type-dyn>` external import types :math:`\externtype^\ast` and external export types :math:`{\externtype'}^\ast`.
2. Let :math:`\import^\ast` be the :ref:`imports <syntax-import>` :math:`\module.\MIMPORTS`.
@@ -179,7 +179,7 @@ Modules
5. Return the concatenation of all :math:`\X{result}_i`, in index order.
-6. Post-condition: each :math:`\externtype_i` is :ref:`valid <valid-externtype>` under the empty :ref:`context <context>`.
+6. Post-condition: each :ref:`dynamic <syntax-type-dyn>` :math:`\externtype_i` is :ref:`valid <valid-externtype>`.
.. math::
~ \\
@@ -195,7 +195,7 @@ Modules
:math:`\F{module\_exports}(\module) : (\name, \externtype)^\ast`
................................................................
-1. Pre-condition: :math:`\module` is :ref:`valid <valid-module>` with the external import types :math:`\externtype^\ast` and external export types :math:`{\externtype'}^\ast`.
+1. Pre-condition: :math:`\module` is :ref:`valid <valid-module>` with the :ref:`dynamic <syntax-type-dyn>` external import types :math:`\externtype^\ast` and external export types :math:`{\externtype'}^\ast`.
2. Let :math:`\export^\ast` be the :ref:`exports <syntax-export>` :math:`\module.\MEXPORTS`.
@@ -207,7 +207,7 @@ Modules
5. Return the concatenation of all :math:`\X{result}_i`, in index order.
-6. Post-condition: each :math:`\externtype'_i` is :ref:`valid <valid-externtype>` under the empty :ref:`context <context>`.
+6. Post-condition: each :ref:`dynamic <syntax-type-dyn>` :math:`\externtype'_i` is :ref:`valid <valid-externtype>`.
.. math::
~ \\
@@ -246,6 +246,29 @@ Module Instances
\end{array}
+.. index:: type, type instance, function type
+.. _embed-type:
+
+Types
+~~~~~
+
+.. _embed-type-alloc:
+
+:math:`\F{type\_alloc}(\store, \functype) : (\store, \typeaddr)`
+...........................................................................
+
+1. Pre-condition: the :ref:`dynamic <syntax-type-dyn>` :math:`\functype` is :ref:`valid <valid-functype>`.
+
+2. Let :math:`\typeaddr` be the result of :ref:`allocating a type <alloc-type>` in :math:`\store` for :ref:`function type <syntax-functype>` :math:`\functype`.
+
+3. Return the new store paired with :math:`\typeaddr`.
+
+.. math::
+ \begin{array}{lclll}
+ \F{type\_alloc}(S, \X{ft}) &=& (S', \X{a}) && (\iff \alloctype(S, \X{ft}) = S', \X{a}) \\
+ \end{array}
+
+
.. index:: function, host function, function address, function instance, function type, store
.. _embed-func:
@@ -254,12 +277,12 @@ Functions
.. _embed-func-alloc:
-:math:`\F{func\_alloc}(\store, \functype, \hostfunc) : (\store, \funcaddr)`
+:math:`\F{func\_alloc}(\store, \typeaddr, \hostfunc) : (\store, \funcaddr)`
...........................................................................
-1. Pre-condition: the :math:`\functype` is :ref:`valid <valid-functype>` under the empty :ref:`context <context>`.
+1. Pre-condition: the :ref:`dynamic <syntax-type-dyn>` :math:`\functype` is :ref:`valid <valid-functype>`.
-2. Let :math:`\funcaddr` be the result of :ref:`allocating a host function <alloc-func>` in :math:`\store` with :ref:`function type <syntax-functype>` :math:`\functype` and host function code :math:`\hostfunc`.
+2. Let :math:`\funcaddr` be the result of :ref:`allocating a host function <alloc-func>` in :math:`\store` with :ref:`type address <syntax-typeaddr>` :math:`\typeaddr` and host function code :math:`\hostfunc`.
3. Return the new store paired with :math:`\funcaddr`.
@@ -279,15 +302,15 @@ Functions
:math:`\F{func\_type}(\store, \funcaddr) : \functype`
.....................................................
-1. Let :math:`\functype` be the :ref:`function type <syntax-functype>` :math:`S.\SFUNCS[a].\FITYPE`.
+1. Let :math:`\typeaddr` be the :ref:`type address <syntax-typeaddr>` :math:`S.\SFUNCS[a].\FITYPE`.
-2. Return :math:`\functype`.
+2. Return :math:`S.\STYPES[\typeaddr]`.
-3. Post-condition: the returned :ref:`function type <syntax-functype>` is :ref:`valid <valid-functype>`.
+3. Post-condition: the returned :ref:`dynamic <syntax-type-dyn>` :ref:`function type <syntax-functype>` is :ref:`valid <valid-functype>`.
.. math::
\begin{array}{lclll}
- \F{func\_type}(S, a) &=& S.\SFUNCS[a].\FITYPE \\
+ \F{func\_type}(S, a) &=& S.\STYPES[S.\SFUNCS[a].\FITYPE] \\
\end{array}
@@ -327,7 +350,7 @@ Tables
:math:`\F{table\_alloc}(\store, \tabletype) : (\store, \tableaddr, \reff)`
..........................................................................
-1. Pre-condition: the :math:`\tabletype` is :ref:`valid <valid-tabletype>` under the empty :ref:`context <context>`.
+1. Pre-condition: the :ref:`dynamic <syntax-type-dyn>` :math:`\tabletype` is :ref:`valid <valid-tabletype>`.
2. Let :math:`\tableaddr` be the result of :ref:`allocating a table <alloc-table>` in :math:`\store` with :ref:`table type <syntax-tabletype>` :math:`\tabletype` and initialization value :math:`\reff`.
@@ -346,7 +369,7 @@ Tables
1. Return :math:`S.\STABLES[a].\TITYPE`.
-2. Post-condition: the returned :ref:`table type <syntax-tabletype>` is :ref:`valid <valid-tabletype>` under the empty :ref:`context <context>`.
+2. Post-condition: the returned :ref:`dynamic <syntax-type-dyn>` :ref:`table type <syntax-tabletype>` is :ref:`valid <valid-tabletype>`.
.. math::
\begin{array}{lclll}
@@ -439,7 +462,7 @@ Memories
:math:`\F{mem\_alloc}(\store, \memtype) : (\store, \memaddr)`
................................................................
-1. Pre-condition: the :math:`\memtype` is :ref:`valid <valid-memtype>` under the empty :ref:`context <context>`.
+1. Pre-condition: the :ref:`dynamic <syntax-type-dyn>` :math:`\memtype` is :ref:`valid <valid-memtype>`.
2. Let :math:`\memaddr` be the result of :ref:`allocating a memory <alloc-mem>` in :math:`\store` with :ref:`memory type <syntax-memtype>` :math:`\memtype`.
@@ -458,7 +481,7 @@ Memories
1. Return :math:`S.\SMEMS[a].\MITYPE`.
-2. Post-condition: the returned :ref:`memory type <syntax-memtype>` is :ref:`valid <valid-memtype>` under the empty :ref:`context <context>`.
+2. Post-condition: the returned :ref:`dynamic <syntax-type-dyn>` :ref:`memory type <syntax-memtype>` is :ref:`valid <valid-memtype>`.
.. math::
\begin{array}{lclll}
@@ -552,7 +575,7 @@ Globals
:math:`\F{global\_alloc}(\store, \globaltype, \val) : (\store, \globaladdr)`
............................................................................
-1. Pre-condition: the :math:`\globaltype` is :ref:`valid <valid-globaltype>` under the empty :ref:`context <context>`.
+1. Pre-condition: the :ref:`dynamic <syntax-type-dyn>` :math:`\globaltype` is :ref:`valid <valid-globaltype>`.
2. Let :math:`\globaladdr` be the result of :ref:`allocating a global <alloc-global>` in :math:`\store` with :ref:`global type <syntax-globaltype>` :math:`\globaltype` and initialization value :math:`\val`.
@@ -571,7 +594,7 @@ Globals
1. Return :math:`S.\SGLOBALS[a].\GITYPE`.
-2. Post-condition: the returned :ref:`global type <syntax-globaltype>` is :ref:`valid <valid-globaltype>` under the empty :ref:`context <context>`.
+2. Post-condition: the returned :ref:`dynamic <syntax-type-dyn>` :ref:`global type <syntax-globaltype>` is :ref:`valid <valid-globaltype>`.
.. math::
\begin{array}{lclll}
diff --git a/document/core/appendix/index-rules.rst b/document/core/appendix/index-rules.rst
index 64f91a51..ba337a76 100644
--- a/document/core/appendix/index-rules.rst
+++ b/document/core/appendix/index-rules.rst
@@ -29,7 +29,7 @@ Construct Judgement
:ref:`Instruction <valid-instr>` :math:`S;C \vdashinstr \instr : \functype`
:ref:`Instruction sequence <valid-instr-seq>` :math:`S;C \vdashinstrseq \instr^\ast : \functype`
:ref:`Expression <valid-expr>` :math:`C \vdashexpr \expr : \resulttype`
-:ref:`Function <valid-func>` :math:`C \vdashfunc \func : \functype`
+:ref:`Function <valid-func>` :math:`C \vdashfunc \func : \typeid`
:ref:`Local <valid-local>` :math:`C \vdashlocal \local : \localtype`
:ref:`Table <valid-table>` :math:`C \vdashtable \table : \tabletype`
:ref:`Memory <valid-mem>` :math:`C \vdashmem \mem : \memtype`
@@ -58,6 +58,7 @@ Construct Judgement
:ref:`Value <valid-val>` :math:`S \vdashval \val : \valtype`
:ref:`Result <valid-result>` :math:`S \vdashresult \result : \resulttype`
:ref:`External value <valid-externval>` :math:`S \vdashexternval \externval : \externtype`
+:ref:`Type instance <valid-typeinst>` :math:`S \vdashtypeinst \typeinst \ok`
:ref:`Function instance <valid-funcinst>` :math:`S \vdashfuncinst \funcinst : \functype`
:ref:`Table instance <valid-tableinst>` :math:`S \vdashtableinst \tableinst : \tabletype`
:ref:`Memory instance <valid-meminst>` :math:`S \vdashmeminst \meminst : \memtype`
@@ -121,6 +122,7 @@ Store Extension
=============================================== ===============================================================================
Construct Judgement
=============================================== ===============================================================================
+:ref:`Type instance <extend-typeinst>` :math:`\vdashtypeinstextends \typeinst_1 \extendsto \typeinst_2`
:ref:`Function instance <extend-funcinst>` :math:`\vdashfuncinstextends \funcinst_1 \extendsto \funcinst_2`
:ref:`Table instance <extend-tableinst>` :math:`\vdashtableinstextends \tableinst_1 \extendsto \tableinst_2`
:ref:`Memory instance <extend-meminst>` :math:`\vdashmeminstextends \meminst_1 \extendsto \meminst_2`
diff --git a/document/core/appendix/properties.rst b/document/core/appendix/properties.rst
index 45e3084b..cd52c399 100644
--- a/document/core/appendix/properties.rst
+++ b/document/core/appendix/properties.rst
@@ -26,14 +26,14 @@ In order to state and prove soundness precisely, the typing rules must be extend
Results
~~~~~~~
-:ref:`Results <syntax-result>` can be classified by :ref:`result types <syntax-resulttype>` as follows.
+:ref:`Results <syntax-result>` can be classified by :ref:`dynamic <syntax-type-dyn>` :ref:`result types <syntax-resulttype>` as follows.
:ref:`Results <syntax-result>` :math:`\val^\ast`
................................................
* For each :ref:`value <syntax-val>` :math:`\val_i` in :math:`\val^\ast`:
- * The value :math:`\val_i` is :ref:`valid <valid-val>` with some :ref:`value type <syntax-valtype>` :math:`t_i`.
+ * The value :math:`\val_i` is :ref:`valid <valid-val>` with some :ref:`dynamic <syntax-type-dyn>` :ref:`value type <syntax-valtype>` :math:`t_i`.
* Let :math:`t^\ast` be the concatenation of all :math:`t_i`.
@@ -50,11 +50,11 @@ Results
:ref:`Results <syntax-result>` :math:`\TRAP`
............................................
-* The result is valid with :ref:`result type <syntax-resulttype>` :math:`[t^\ast]`, for any :ref:`valid <valid-resulttype>` :ref:`closed <type-closed>` :ref:`result types <syntax-resulttype>`.
+* The result is valid with :ref:`result type <syntax-resulttype>` :math:`[t^\ast]`, for any :ref:`valid <valid-resulttype>` :ref:`dynamic <syntax-type-dyn>` :ref:`result types <syntax-resulttype>`.
.. math::
\frac{
- \vdashresulttype [t^\ast] \ok
+ S \vdashresulttype [t^\ast] \ok
}{
S \vdashresult \TRAP : [t^\ast]
}
@@ -80,7 +80,9 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
:ref:`Store <syntax-store>` :math:`S`
.....................................
-* Each :ref:`function instance <syntax-funcinst>` :math:`\funcinst_i` in :math:`S.\SFUNCS` must be :ref:`valid <valid-funcinst>` with some :ref:`function type <syntax-functype>` :math:`\functype_i`.
+* Each :ref:`type instance <syntax-typeinst>` :math:`\typeinst_i` in :math:`S.\STYPES` must be :ref:`valid <valid-functype>` in a store :math:`S'_i` only containing the sequence :math:`\typeinst_0 \dots \typeinst_{i-1}` of preceding type instances.
+
+* Each :ref:`function instance <syntax-funcinst>` :math:`\funcinst_i` in :math:`S.\SFUNCS` must be :ref:`valid <valid-funcinst>` with some :ref:`type address <syntax-typeaddr>` :math:`\typeaddr_i`.
* Each :ref:`table instance <syntax-tableinst>` :math:`\tableinst_i` in :math:`S.\STABLES` must be :ref:`valid <valid-tableinst>` with some :ref:`table type <syntax-tabletype>` :math:`\tabletype_i`.
@@ -98,7 +100,11 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
~\\[-1ex]
\frac{
\begin{array}{@{}c@{}}
- (S \vdashfuncinst \funcinst : \functype)^\ast
+ a^n = 0 \dots (n-1)
+ \qquad
+ (\{\STYPES~\typeinst^n[0 \slice a]\} \vdashtypeinst \typeinst \ok)^n
+ \\
+ (S \vdashfuncinst \funcinst : \typeaddr)^\ast
\qquad
(S \vdashtableinst \tableinst : \tabletype)^\ast
\\
@@ -112,6 +118,7 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
\\
S = \{
\begin{array}[t]{@{}l@{}}
+ \STYPES~\typeinst^n,
\SFUNCS~\funcinst^\ast,
\SGLOBALS~\globalinst^\ast, \\
\STABLES~\tableinst^\ast,
@@ -128,49 +135,63 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
The validity condition on type instances ensures the absence of cyclic types.
+.. index:: function type, type instance
+.. _valid-typeinst:
+
+:ref:`Type Instances <syntax-typeinst>` :math:`\functype`
+.........................................................
+
+* The :ref:`dynamic <syntax-type-dyn>` :ref:`function type <syntax-functype>` :math:`\functype` must be :ref:`valid <valid-functype>`.
+
+* Then it is valid as a type instance.
+
+.. math::
+ \frac{
+ S \vdashfunctype \functype \ok
+ }{
+ S \vdashtypeinst \functype \ok
+ }
+
+
.. index:: function type, function instance
.. _valid-funcinst:
-:ref:`Function Instances <syntax-funcinst>` :math:`\{\FITYPE~\functype, \FIMODULE~\moduleinst, \FICODE~\func\}`
+:ref:`Function Instances <syntax-funcinst>` :math:`\{\FITYPE~\typeaddr, \FIMODULE~\moduleinst, \FICODE~\func\}`
.......................................................................................................................
-* The :ref:`function type <syntax-functype>` :math:`\functype` must be :ref:`valid <valid-functype>` under an empty :ref:`context <context>`.
-
* The :ref:`module instance <syntax-moduleinst>` :math:`\moduleinst` must be :ref:`valid <valid-moduleinst>` with some :ref:`context <context>` :math:`C`.
* Under :ref:`context <context>` :math:`C`:
- * The :ref:`function <syntax-func>` :math:`\func` must be :ref:`valid <valid-func>` with some :ref:`function type <syntax-functype>` :math:`\functype'`.
+ * The :ref:`function <syntax-func>` :math:`\func` must be :ref:`valid <valid-func>` with :ref:`static <syntax-type-stat>` :ref:`type identifier <syntax-typeid>` :math:`\typeidx`.
- * The :ref:`function type <syntax-functype>` :math:`\functype'` must :ref:`match <match-functype>` :math:`\functype`.
+ * The :ref:`static <syntax-type-stat>` :ref:`heap type <syntax-heaptype>` :math:`\typeidx` must :ref:`match <match-heaptype>` the :ref:`dynamic <syntax-type-dyn>` :ref:`heap type <syntax-heaptype>` :math:`\typeaddr`.
-* Then the function instance is valid with :ref:`function type <syntax-functype>` :math:`\functype`.
+* Then the function instance is valid with :ref:`type address <syntax-typeaddr>` :math:`\typeaddr`.
.. math::
\frac{
\begin{array}{@{}c@{}}
- \vdashfunctype \functype \ok
- \qquad
S \vdashmoduleinst \moduleinst : C
\\
- C \vdashfunc \func : \functype'
+ C \vdashfunc \func : \typeidx
\qquad
- C \vdashfunctypematch \functype' \matchesfunctype \functype
+ C; S \vdashheaptypematch \typeidx \matchesheaptype \typeaddr
\end{array}
}{
- S \vdashfuncinst \{\FITYPE~\functype, \FIMODULE~\moduleinst, \FICODE~\func\} : \functype
+ S \vdashfuncinst \{\FITYPE~\typeaddr, \FIMODULE~\moduleinst, \FICODE~\func\} : \typeaddr
}
.. index:: function type, function instance, host function
.. _valid-hostfuncinst:
-:ref:`Host Function Instances <syntax-funcinst>` :math:`\{\FITYPE~\functype, \FIHOSTCODE~\X{hf}\}`
+:ref:`Host Function Instances <syntax-funcinst>` :math:`\{\FITYPE~\typeaddr, \FIHOSTCODE~\X{hf}\}`
..................................................................................................
-* The :ref:`function type <syntax-functype>` :math:`\functype` must be :ref:`valid <valid-functype>` under an empty :ref:`context <context>`.
+* The :ref:`type instance <syntax-typeinst>` :math:`S.\STYPES[\typeaddr]` must exist.
-* Let :math:`[t_1^\ast] \toF [t_2^\ast]` be the :ref:`function type <syntax-functype>` :math:`\functype`.
+* Let the :ref:`dynamic <syntax-type-dyn>` :ref:`function type <syntax-functype>` :math:`[t_1^\ast] \toF [t_2^\ast]` be the :ref:`type instance <syntax-typeinst>` :math:`S.\STYPES[\typeaddr]`.
* For every :ref:`valid <valid-store>` :ref:`store <syntax-store>` :math:`S_1` :ref:`extending <extend-store>` :math:`S` and every sequence :math:`\val^\ast` of :ref:`values <syntax-val>` whose :ref:`types <valid-val>` coincide with :math:`t_1^\ast`:
@@ -182,12 +203,12 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
* Or :math:`R` consists of a :ref:`valid <valid-store>` :ref:`store <syntax-store>` :math:`S_2` :ref:`extending <extend-store>` :math:`S_1` and a :ref:`result <syntax-result>` :math:`\result` whose :ref:`type <valid-result>` coincides with :math:`[t_2^\ast]`.
-* Then the function instance is valid with :ref:`function type <syntax-functype>` :math:`\functype`.
+* Then the function instance is valid with :ref:`type address <syntax-typeaddr>` :math:`\typeaddr`.
.. math::
\frac{
\begin{array}[b]{@{}l@{}}
- \vdashfunctype [t_1^\ast] \toF [t_2^\ast] \ok \\
+ S.\STYPES[\typeaddr] = [t_1^\ast] \toF [t_2^\ast] \\
\end{array}
\quad
\begin{array}[b]{@{}l@{}}
@@ -206,7 +227,7 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
R = (S_2; \result)
\end{array}
}{
- S \vdashfuncinst \{\FITYPE~[t_1^\ast] \to [t_2^\ast], \FIHOSTCODE~\X{hf}\} : [t_1^\ast] \to [t_2^\ast]
+ S \vdashfuncinst \{\FITYPE~\typeaddr, \FIHOSTCODE~\X{hf}\} : \typeaddr
}
.. note::
@@ -223,7 +244,7 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
:ref:`Table Instances <syntax-tableinst>` :math:`\{ \TITYPE~(\limits~t), \TIELEM~\reff^\ast \}`
...............................................................................................
-* The :ref:`table type <syntax-tabletype>` :math:`\limits~t` must be :ref:`valid <valid-tabletype>` under the empty :ref:`context <context>`.
+* The :ref:`dynamic <syntax-type-dyn>` :ref:`table type <syntax-tabletype>` :math:`\limits~t` must be :ref:`valid <valid-tabletype>`.
* The length of :math:`\reff^\ast` must equal :math:`\limits.\LMIN`.
@@ -237,13 +258,13 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
.. math::
\frac{
- \vdashtabletype \limits~t \ok
+ S \vdashtabletype \limits~t \ok
\qquad
n = \limits.\LMIN
\qquad
(S \vdash \reff : t')^n
\qquad
- (\vdashreftypematch t' \matchesvaltype t)^n
+ (S \vdashreftypematch t' \matchesvaltype t)^n
}{
S \vdashtableinst \{ \TITYPE~(\limits~t), \TIELEM~\reff^n \} : \limits~t
}
@@ -255,7 +276,7 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
:ref:`Memory Instances <syntax-meminst>` :math:`\{ \MITYPE~\limits, \MIDATA~b^\ast \}`
......................................................................................
-* The :ref:`memory type <syntax-memtype>` :math:`\limits` must be :ref:`valid <valid-memtype>` under the empty :ref:`context <context>`.
+* The :ref:`dynamic <syntax-type-dyn>` :ref:`memory type <syntax-memtype>` :math:`\limits` must be :ref:`valid <valid-memtype>`.
* The length of :math:`b^\ast` must equal :math:`\limits.\LMIN` multiplied by the :ref:`page size <page-size>` :math:`64\,\F{Ki}`.
@@ -263,7 +284,7 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
.. math::
\frac{
- \vdashmemtype \limits \ok
+ S \vdashmemtype \limits \ok
\qquad
n = \limits.\LMIN \cdot 64\,\F{Ki}
}{
@@ -277,7 +298,7 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
:ref:`Global Instances <syntax-globalinst>` :math:`\{ \GITYPE~(\mut~t), \GIVALUE~\val \}`
.........................................................................................
-* The :ref:`global type <syntax-globaltype>` :math:`\mut~t` must be :ref:`valid <valid-globaltype>` under the empty :ref:`context <context>`.
+* The :ref:`dynamic <syntax-type-dyn>` :ref:`global type <syntax-globaltype>` :math:`\mut~t` must be :ref:`valid <valid-globaltype>`.
* The :ref:`value <syntax-val>` :math:`\val` must be :ref:`valid <valid-val>` with some :ref:`value type <syntax-valtype>` :math:`t'`.
@@ -287,11 +308,11 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
.. math::
\frac{
- \vdashglobaltype \mut~t \ok
+ S \vdashglobaltype \mut~t \ok
\qquad
S \vdashval \val : t'
\qquad
- \vdashvaltypematch t' \matchesvaltype t
+ S \vdashvaltypematch t' \matchesvaltype t
}{
S \vdashglobalinst \{ \GITYPE~(\mut~t), \GIVALUE~\val \} : \mut~t
}
@@ -303,7 +324,7 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
:ref:`Element Instances <syntax-eleminst>` :math:`\{ \EIELEM~\X{fa}^\ast \}`
............................................................................
-* The :ref:`reference type <syntax-reftype>` :math:`t` must be :ref:`valid <valid-reftype>` under the empty :ref:`context <context>`.
+* The :ref:`dynamic <syntax-type-dyn>` :ref:`reference type <syntax-reftype>` :math:`t` must be :ref:`valid <valid-reftype>`.
* For each :ref:`reference <syntax-ref>` :math:`\reff_i` in the elements :math:`\reff^n`:
@@ -315,11 +336,11 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
.. math::
\frac{
- \vdashreftype t \ok
+ S \vdashreftype t \ok
\qquad
(S \vdash \reff : t')^\ast
\qquad
- (\vdashreftypematch t' \matchesvaltype t)^\ast
+ (S \vdashreftypematch t' \matchesvaltype t)^\ast
}{
S \vdasheleminst \{ \EITYPE~t, \EIELEM~\reff^\ast \} : t
}
@@ -364,9 +385,9 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
:ref:`Module Instances <syntax-moduleinst>` :math:`\moduleinst`
...............................................................
-* Each :ref:`defined type <syntax-deftype>` :math:`\deftype_i` in :math:`\moduleinst.\MITYPES` must be :ref:`valid <valid-deftype>`.
+* For each :ref:`type address <syntax-typeaddr>` :math:`\typeaddr_i` in :math:`\moduleinst.\MITYPES`, the :ref:`type instance <syntax-typeinst>` :math:`\typeinst_i` at :math:`S.\STYPES[\typeaddr_i]` must be :ref:`valid <valid-typeinst>`.
-* For each :ref:`function address <syntax-funcaddr>` :math:`\funcaddr_i` in :math:`\moduleinst.\MIFUNCS`, the :ref:`external value <syntax-externval>` :math:`\EVFUNC~\funcaddr_i` must be :ref:`valid <valid-externval-func>` with some :ref:`external type <syntax-externtype>` :math:`\ETFUNC~\functype_i`.
+* For each :ref:`function address <syntax-funcaddr>` :math:`\funcaddr_i` in :math:`\moduleinst.\MIFUNCS`, the :ref:`external value <syntax-externval>` :math:`\EVFUNC~\funcaddr_i` must be :ref:`valid <valid-externval-func>` with some :ref:`external type <syntax-externtype>` :math:`\ETFUNC~\typeaddr'_i`.
* For each :ref:`table address <syntax-tableaddr>` :math:`\tableaddr_i` in :math:`\moduleinst.\MITABLES`, the :ref:`external value <syntax-externval>` :math:`\EVTABLE~\tableaddr_i` must be :ref:`valid <valid-externval-table>` with some :ref:`external type <syntax-externtype>` :math:`\ETTABLE~\tabletype_i`.
@@ -382,9 +403,9 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
* For each :ref:`export instance <syntax-exportinst>` :math:`\exportinst_i` in :math:`\moduleinst.\MIEXPORTS`, the :ref:`name <syntax-name>` :math:`\exportinst_i.\EINAME` must be different from any other name occurring in :math:`\moduleinst.\MIEXPORTS`.
-* Let :math:`\deftype^\ast` be the concatenation of all :math:`\deftype_i` in order.
+* Let :math:`\typeinst^\ast` be the concatenation of all :math:`\typeinst_i` in order.
-* Let :math:`\functype^\ast` be the concatenation of all :math:`\functype_i` in order.
+* Let :math:`\typeaddr'^\ast` be the concatenation of all :math:`\typeaddr'_i` in order.
* Let :math:`\tabletype^\ast` be the concatenation of all :math:`\tabletype_i` in order.
@@ -397,15 +418,15 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
* Let :math:`n` be the length of :math:`\moduleinst.\MIDATAS`.
* Then the module instance is valid with :ref:`context <context>`
- :math:`\{\CTYPES~\deftype^\ast,` :math:`\CFUNCS~\functype^\ast,` :math:`\CTABLES~\tabletype^\ast,` :math:`\CMEMS~\memtype^\ast,` :math:`\CGLOBALS~\globaltype^\ast,` :math:`\CELEMS~\reftype^\ast,` :math:`\CDATAS~{\ok}^n\}`.
+ :math:`\{\CTYPES~\typeinst^\ast,` :math:`\CFUNCS~{\typeaddr'}^\ast,` :math:`\CTABLES~\tabletype^\ast,` :math:`\CMEMS~\memtype^\ast,` :math:`\CGLOBALS~\globaltype^\ast,` :math:`\CELEMS~\reftype^\ast,` :math:`\CDATAS~{\ok}^n\}`.
.. math::
~\\[-1ex]
\frac{
\begin{array}{@{}c@{}}
- (\vdashdeftype \deftype \ok)^\ast
+ (S \vdashtypeinst S.\STYPES[\typeaddr] \ok)^\ast
\\
- (S \vdashexternval \EVFUNC~\funcaddr : \ETFUNC~\functype)^\ast
+ (S \vdashexternval \EVFUNC~\funcaddr : \ETFUNC~\typeaddr')^\ast
\qquad
(S \vdashexternval \EVTABLE~\tableaddr : \ETTABLE~\tabletype)^\ast
\\
@@ -424,7 +445,7 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
}{
S \vdashmoduleinst \{
\begin{array}[t]{@{}l@{~}l@{}}
- \MITYPES & \deftype^\ast, \\
+ \MITYPES & \typeaddr^\ast, \\
\MIFUNCS & \funcaddr^\ast, \\
\MITABLES & \tableaddr^\ast, \\
\MIMEMS & \memaddr^\ast, \\
@@ -433,8 +454,8 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
\MIDATAS & \dataaddr^n, \\
\MIEXPORTS & \exportinst^\ast ~\} : \{
\begin{array}[t]{@{}l@{~}l@{}}
- \CTYPES & \deftype^\ast, \\
- \CFUNCS & \functype^\ast, \\
+ \CTYPES & S.\STYPES[\typeaddr]^\ast, \\
+ \CFUNCS & {\typeaddr'}^\ast, \\
\CTABLES & \tabletype^\ast, \\
\CMEMS & \memtype^\ast, \\
\CGLOBALS & \globaltype^\ast, \\
@@ -444,6 +465,9 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
\end{array}
}
+.. note::
+ The context derived for a module instance consists of :ref:`dynamic types <syntax-type-dyn>`.
+
.. scratch
.. index:: context, store, frame
@@ -562,7 +586,7 @@ Finally, :ref:`frames <syntax-frame>` are classified with *frame contexts*, whic
:ref:`Frames <syntax-frame>` :math:`\{\ALOCALS~\val^\ast, \AMODULE~\moduleinst\}`
.................................................................................
-* The :ref:`module instance <syntax-moduleinst>` :math:`\moduleinst` must be :ref:`valid <valid-moduleinst>` with some :ref:`module context <module-context>` :math:`C`.
+* The :ref:`module instance <syntax-moduleinst>` :math:`\moduleinst` must be :ref:`valid <valid-moduleinst>` with some :ref:`dynamic <syntax-type-dyn>` :ref:`module context <module-context>` :math:`C`.
* Each :ref:`value <syntax-val>` :math:`\val_i` in :math:`\val^\ast` must be :ref:`valid <valid-val>` with some :ref:`value type <syntax-valtype>` :math:`t_i`.
@@ -599,11 +623,11 @@ To that end, all previous typing judgements :math:`C \vdash \X{prop}` are genera
:math:`\TRAP`
.............
-* The instruction is valid with any :ref:`valid <valid-instrtype>` :ref:`instruction type <syntax-instrtype>` of the form :math:`[t_1^\ast] \to [t_2^\ast]`.
+* The instruction is valid with any :ref:`valid <valid-instrtype>` :ref:`dynamic <syntax-type-dyn>` :ref:`instruction type <syntax-instrtype>` of the form :math:`[t_1^\ast] \to [t_2^\ast]`.
.. math::
\frac{
- C \vdashinstrtype [t_1^\ast] \to [t_2^\ast] \ok
+ S; C \vdashinstrtype [t_1^\ast] \to [t_2^\ast] \ok
}{
S; C \vdashadmininstr \TRAP : [t_1^\ast] \to [t_2^\ast]
}
@@ -628,32 +652,41 @@ To that end, all previous typing judgements :math:`C \vdash \X{prop}` are genera
:math:`\REFFUNCADDR~\funcaddr`
..............................
-* The :ref:`external function value <syntax-externval>` :math:`\EVFUNC~\funcaddr` must be :ref:`valid <valid-externval>` with :ref:`external function type <syntax-externtype>` :math:`\ETFUNC~\functype`.
+* The :ref:`external function value <syntax-externval>` :math:`\EVFUNC~\funcaddr` must be :ref:`valid <valid-externval>` with :ref:`dynamic <syntax-type-dyn>` :ref:`external function type <syntax-externtype>` :math:`\ETFUNC~a'`.
-* Then the instruction is valid with type :math:`[] \to [(\REF~\functype)]`.
+* Then the instruction is valid with type :math:`[] \to [(\REF~a')]`.
.. math::
\frac{
- S \vdashexternval \EVFUNC~a : \ETFUNC~\functype
+ S \vdashexternval \EVFUNC~a : \ETFUNC~a'
}{
- S; C \vdashadmininstr \REFFUNCADDR~a : [] \to [(\REF~\functype)]
+ S; C \vdashadmininstr \REFFUNCADDR~a : [] \to [(\REF~a')]
}
+.. note::
+ This typing rule yields a :ref:`dynamic <syntax-type-dyn>` type.
+ The function may originate from outside the current module,
+ so that a definition for its type may not exist in context :math:`C`.
+
.. index:: function address, extern value, extern type, function type
:math:`\INVOKE~\funcaddr`
.........................
-* The :ref:`external function value <syntax-externval>` :math:`\EVFUNC~\funcaddr` must be :ref:`valid <valid-externval-func>` with :ref:`external function type <syntax-externtype>` :math:`\ETFUNC \functype'`.
+* The :ref:`external function value <syntax-externval>` :math:`\EVFUNC~\funcaddr` must be :ref:`valid <valid-externval-func>` with :ref:`external function type <syntax-externtype>` :math:`\ETFUNC a'`.
+
+* Assert: The :ref:`type address <syntax-typeaddr>` :math:`S.\STYPES[a']` is defined in the store.
-* Let :math:`[t_1^\ast] \toF [t_2^\ast])` be the :ref:`function type <syntax-functype>` :math:`\functype`.
+* Let :math:`[t_1^\ast] \toF [t_2^\ast])` be the :ref:`function type <syntax-functype>` :math:`S.\STYPES[a']`.
* Then the instruction is valid with type :math:`[t_1^\ast] \to [t_2^\ast]`.
.. math::
\frac{
- S \vdashexternval \EVFUNC~\funcaddr : \ETFUNC~[t_1^\ast] \toF [t_2^\ast]
+ S \vdashexternval \EVFUNC~\funcaddr : \ETFUNC~a'
+ \qquad
+ S.\STYPES[a'] = [t_1^\ast] \toF [t_2^\ast]