├── .gitattributes ├── .github └── workflows │ ├── ci-interpreter.yml │ ├── ci-spec.yml │ ├── mirror-to-master.yml │ └── w3c-publish.yml ├── .gitignore ├── .gitmodules ├── Contributing.md ├── LICENSE ├── README.md ├── document ├── Makefile ├── README.md ├── core │ ├── .gitignore │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── appendix │ │ ├── algorithm.rst │ │ ├── changes.rst │ │ ├── custom.rst │ │ ├── embedding.rst │ │ ├── implementation.rst │ │ ├── index-instructions.py │ │ ├── index-rules.rst │ │ ├── index-types.rst │ │ ├── index.rst │ │ └── properties.rst │ ├── binary │ │ ├── conventions.rst │ │ ├── index.rst │ │ ├── instructions.rst │ │ ├── modules.rst │ │ ├── types.rst │ │ └── values.rst │ ├── conf.py │ ├── exec │ │ ├── conventions.rst │ │ ├── index.rst │ │ ├── instructions.rst │ │ ├── modules.rst │ │ ├── numerics.rst │ │ ├── runtime.rst │ │ ├── types.rst │ │ └── values.rst │ ├── index.bs │ ├── index.rst │ ├── intro │ │ ├── index.rst │ │ ├── introduction.rst │ │ └── overview.rst │ ├── make.bat │ ├── static │ │ ├── custom.css │ │ └── webassembly.png │ ├── syntax │ │ ├── conventions.rst │ │ ├── index.rst │ │ ├── instructions.rst │ │ ├── modules.rst │ │ ├── types.rst │ │ └── values.rst │ ├── text │ │ ├── conventions.rst │ │ ├── index.rst │ │ ├── instructions.rst │ │ ├── lexical.rst │ │ ├── modules.rst │ │ ├── types.rst │ │ └── values.rst │ ├── util │ │ ├── README.htmldiff.pl │ │ ├── bikeshed │ │ │ └── conf.py │ │ ├── bikeshed_fixup.py │ │ ├── check_macros.sh │ │ ├── katex_fix.patch │ │ ├── macros.def │ │ ├── mathdef.py │ │ ├── mathdefbs.py │ │ ├── mathjax2katex.py │ │ └── pseudo-lexer.py │ └── valid │ │ ├── conventions.rst │ │ ├── index.rst │ │ ├── instructions.rst │ │ ├── matching.rst │ │ ├── modules.rst │ │ └── types.rst ├── deploy.sh ├── index.html ├── js-api │ ├── Makefile │ └── index.bs ├── util │ └── htmldiff.pl └── web-api │ ├── Makefile │ └── index.bs ├── interpreter ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── binary │ ├── decode.ml │ ├── decode.mli │ ├── encode.ml │ ├── encode.mli │ ├── utf8.ml │ └── utf8.mli ├── dune ├── dune-project ├── exec │ ├── eval.ml │ ├── eval.mli │ ├── eval_num.ml │ ├── eval_num.mli │ ├── eval_vec.ml │ ├── eval_vec.mli │ ├── f32.ml │ ├── f32_convert.ml │ ├── f32_convert.mli │ ├── f64.ml │ ├── f64_convert.ml │ ├── f64_convert.mli │ ├── fxx.ml │ ├── i16.ml │ ├── i32.ml │ ├── i32_convert.ml │ ├── i32_convert.mli │ ├── i64.ml │ ├── i64_convert.ml │ ├── i64_convert.mli │ ├── i8.ml │ ├── ixx.ml │ ├── v128.ml │ └── v128.mli ├── host │ ├── env.ml │ └── spectest.ml ├── jslib │ └── wast.ml ├── main │ ├── flags.ml │ └── main.ml ├── runtime │ ├── data.ml │ ├── data.mli │ ├── elem.ml │ ├── elem.mli │ ├── func.ml │ ├── func.mli │ ├── global.ml │ ├── global.mli │ ├── instance.ml │ ├── memory.ml │ ├── memory.mli │ ├── table.ml │ ├── table.mli │ └── value.ml ├── script │ ├── import.ml │ ├── import.mli │ ├── js.ml │ ├── js.mli │ ├── run.ml │ ├── run.mli │ └── script.ml ├── syntax │ ├── ast.ml │ ├── free.ml │ ├── free.mli │ ├── operators.ml │ ├── pack.ml │ └── types.ml ├── text │ ├── arrange.ml │ ├── arrange.mli │ ├── lexer.mli │ ├── lexer.mll │ ├── parse.ml │ ├── parse.mli │ ├── parse_error.ml │ ├── parser.mly │ ├── print.ml │ └── print.mli ├── unittest │ └── smallint.ml ├── util │ ├── error.ml │ ├── error.mli │ ├── lib.ml │ ├── lib.mli │ ├── sexpr.ml │ ├── sexpr.mli │ ├── source.ml │ └── source.mli ├── valid │ ├── match.ml │ ├── match.mli │ ├── valid.ml │ └── valid.mli └── wasm.opam ├── papers ├── LICENSE ├── README.md ├── oopsla2019.pdf └── pldi2017.pdf ├── proposals ├── README.md ├── bulk-memory-operations │ └── Overview.md ├── function-references │ └── Overview.md ├── multi-value │ └── Overview.md ├── nontrapping-float-to-int-conversion │ └── Overview.md ├── reference-types │ └── Overview.md ├── sign-extension-ops │ └── Overview.md ├── simd │ ├── BinarySIMD.md │ ├── ImplementationStatus.md │ ├── NewOpcodes.md │ ├── SIMD.md │ ├── TextSIMD.md │ ├── W3CTAG-SIMDExplainer.md │ └── WebAssembly-SIMD-May-2017.pdf └── tail-call │ └── Overview.md ├── test ├── LICENSE ├── README.md ├── Todo.md ├── build.py ├── core │ ├── .gitignore │ ├── README.md │ ├── address.wast │ ├── align.wast │ ├── binary-leb128.wast │ ├── binary.wast │ ├── block.wast │ ├── br.wast │ ├── br_if.wast │ ├── br_on_non_null.wast │ ├── br_on_null.wast │ ├── br_table.wast │ ├── bulk.wast │ ├── call.wast │ ├── call_indirect.wast │ ├── call_ref.wast │ ├── comments.wast │ ├── const.wast │ ├── conversions.wast │ ├── custom.wast │ ├── data.wast │ ├── elem.wast │ ├── endianness.wast │ ├── exports.wast │ ├── f32.wast │ ├── f32_bitwise.wast │ ├── f32_cmp.wast │ ├── f64.wast │ ├── f64_bitwise.wast │ ├── f64_cmp.wast │ ├── fac.wast │ ├── float_exprs.wast │ ├── float_literals.wast │ ├── float_memory.wast │ ├── float_misc.wast │ ├── forward.wast │ ├── func.wast │ ├── func_ptrs.wast │ ├── global.wast │ ├── i32.wast │ ├── i64.wast │ ├── if.wast │ ├── imports.wast │ ├── inline-module.wast │ ├── int_exprs.wast │ ├── int_literals.wast │ ├── labels.wast │ ├── left-to-right.wast │ ├── linking.wast │ ├── load.wast │ ├── local_get.wast │ ├── local_init.wast │ ├── local_set.wast │ ├── local_tee.wast │ ├── loop.wast │ ├── memory.wast │ ├── memory_copy.wast │ ├── memory_fill.wast │ ├── memory_grow.wast │ ├── memory_init.wast │ ├── memory_redundancy.wast │ ├── memory_size.wast │ ├── memory_trap.wast │ ├── names.wast │ ├── nop.wast │ ├── obsolete-keywords.wast │ ├── ref.wast │ ├── ref_as_non_null.wast │ ├── ref_func.wast │ ├── ref_is_null.wast │ ├── ref_null.wast │ ├── return.wast │ ├── return_call.wast │ ├── return_call_indirect.wast │ ├── return_call_ref.wast │ ├── run.py │ ├── select.wast │ ├── simd │ │ ├── meta │ │ │ ├── README.md │ │ │ ├── gen_tests.py │ │ │ ├── simd.py │ │ │ ├── simd_arithmetic.py │ │ │ ├── simd_bitwise.py │ │ │ ├── simd_compare.py │ │ │ ├── simd_ext_mul.py │ │ │ ├── simd_extadd_pairwise.py │ │ │ ├── simd_f32x4.py │ │ │ ├── simd_f32x4_arith.py │ │ │ ├── simd_f32x4_cmp.py │ │ │ ├── simd_f32x4_pmin_pmax.py │ │ │ ├── simd_f32x4_rounding.py │ │ │ ├── simd_f64x2.py │ │ │ ├── simd_f64x2_arith.py │ │ │ ├── simd_f64x2_cmp.py │ │ │ ├── simd_f64x2_pmin_pmax.py │ │ │ ├── simd_f64x2_rounding.py │ │ │ ├── simd_float_op.py │ │ │ ├── simd_i16x8_arith.py │ │ │ ├── simd_i16x8_cmp.py │ │ │ ├── simd_i16x8_q15mulr_sat_s.py │ │ │ ├── simd_i32x4_arith.py │ │ │ ├── simd_i32x4_cmp.py │ │ │ ├── simd_i32x4_dot_i16x8.py │ │ │ ├── simd_i64x2_arith.py │ │ │ ├── simd_i64x2_cmp.py │ │ │ ├── simd_i8x16_arith.py │ │ │ ├── simd_i8x16_cmp.py │ │ │ ├── simd_int_arith2.py │ │ │ ├── simd_int_to_int_extend.py │ │ │ ├── simd_int_trunc_sat_float.py │ │ │ ├── simd_integer_op.py │ │ │ ├── simd_lane_value.py │ │ │ ├── simd_load_lane.py │ │ │ ├── simd_sat_arith.py │ │ │ ├── simd_store_lane.py │ │ │ └── test_assert.py │ │ ├── simd_address.wast │ │ ├── simd_align.wast │ │ ├── simd_bit_shift.wast │ │ ├── simd_bitwise.wast │ │ ├── simd_boolean.wast │ │ ├── simd_const.wast │ │ ├── simd_conversions.wast │ │ ├── simd_f32x4.wast │ │ ├── simd_f32x4_arith.wast │ │ ├── simd_f32x4_cmp.wast │ │ ├── simd_f32x4_pmin_pmax.wast │ │ ├── simd_f32x4_rounding.wast │ │ ├── simd_f64x2.wast │ │ ├── simd_f64x2_arith.wast │ │ ├── simd_f64x2_cmp.wast │ │ ├── simd_f64x2_pmin_pmax.wast │ │ ├── simd_f64x2_rounding.wast │ │ ├── simd_i16x8_arith.wast │ │ ├── simd_i16x8_arith2.wast │ │ ├── simd_i16x8_cmp.wast │ │ ├── simd_i16x8_extadd_pairwise_i8x16.wast │ │ ├── simd_i16x8_extmul_i8x16.wast │ │ ├── simd_i16x8_q15mulr_sat_s.wast │ │ ├── simd_i16x8_sat_arith.wast │ │ ├── simd_i32x4_arith.wast │ │ ├── simd_i32x4_arith2.wast │ │ ├── simd_i32x4_cmp.wast │ │ ├── simd_i32x4_dot_i16x8.wast │ │ ├── simd_i32x4_extadd_pairwise_i16x8.wast │ │ ├── simd_i32x4_extmul_i16x8.wast │ │ ├── simd_i32x4_trunc_sat_f32x4.wast │ │ ├── simd_i32x4_trunc_sat_f64x2.wast │ │ ├── simd_i64x2_arith.wast │ │ ├── simd_i64x2_arith2.wast │ │ ├── simd_i64x2_cmp.wast │ │ ├── simd_i64x2_extmul_i32x4.wast │ │ ├── simd_i8x16_arith.wast │ │ ├── simd_i8x16_arith2.wast │ │ ├── simd_i8x16_cmp.wast │ │ ├── simd_i8x16_sat_arith.wast │ │ ├── simd_int_to_int_extend.wast │ │ ├── simd_lane.wast │ │ ├── simd_linking.wast │ │ ├── simd_load.wast │ │ ├── simd_load16_lane.wast │ │ ├── simd_load32_lane.wast │ │ ├── simd_load64_lane.wast │ │ ├── simd_load8_lane.wast │ │ ├── simd_load_extend.wast │ │ ├── simd_load_splat.wast │ │ ├── simd_load_zero.wast │ │ ├── simd_splat.wast │ │ ├── simd_store.wast │ │ ├── simd_store16_lane.wast │ │ ├── simd_store32_lane.wast │ │ ├── simd_store64_lane.wast │ │ └── simd_store8_lane.wast │ ├── skip-stack-guard-page.wast │ ├── stack.wast │ ├── start.wast │ ├── store.wast │ ├── switch.wast │ ├── table-sub.wast │ ├── table.wast │ ├── table_copy.wast │ ├── table_fill.wast │ ├── table_get.wast │ ├── table_grow.wast │ ├── table_init.wast │ ├── table_set.wast │ ├── table_size.wast │ ├── token.wast │ ├── traps.wast │ ├── type-equivalence.wast │ ├── type.wast │ ├── unreachable.wast │ ├── unreached-invalid.wast │ ├── unreached-valid.wast │ ├── unwind.wast │ ├── utf8-custom-section-id.wast │ ├── utf8-import-field.wast │ ├── utf8-import-module.wast │ └── utf8-invalid-encoding.wast ├── harness │ ├── async_index.js │ ├── sync_index.js │ ├── testharness.css │ ├── testharness.js │ └── testharnessreport.js ├── js-api │ ├── LICENSE.md │ ├── README.md │ ├── assertions.js │ ├── bad-imports.js │ ├── constructor │ ├── error-interfaces-no-symbol-tostringtag.js │ ├── functions │ │ └── helper.js │ ├── global │ │ ├── constructor.any.js │ │ ├── toString.any.js │ │ ├── value-get-set.any.js │ │ └── valueOf.any.js │ ├── instance │ │ ├── constructor-bad-imports.any.js │ │ ├── constructor-caching.any.js │ │ ├── constructor.any.js │ │ ├── exports.any.js │ │ └── toString.any.js │ ├── instanceTestFactory.js │ ├── interface.any.js │ ├── limits.any.js │ ├── memory │ │ ├── assertions.js │ │ ├── buffer.any.js │ │ ├── constructor.any.js │ │ ├── grow.any.js │ │ └── toString.any.js │ ├── module │ │ ├── constructor.any.js │ │ ├── customSections.any.js │ │ ├── exports.any.js │ │ ├── imports.any.js │ │ └── toString.any.js │ ├── prototypes.any.js │ ├── table │ │ ├── assertions.js │ │ ├── constructor.any.js │ │ ├── get-set.any.js │ │ ├── grow.any.js │ │ ├── length.any.js │ │ └── toString.any.js │ └── wasm-module-builder.js ├── meta │ ├── Makefile │ ├── README.md │ ├── common.js │ ├── generate_memory_copy.js │ ├── generate_memory_fill.js │ ├── generate_memory_init.js │ ├── generate_table_copy.js │ ├── generate_table_init.js │ └── noderun.sh └── sync-js-api.py ├── w3c.json └── wasm-specs.bib /.gitattributes: -------------------------------------------------------------------------------- 1 | *.rst linguist-documentation=false 2 | document/* linguist-documentation=false 3 | document/*.rst linguist-documentation=false 4 | document/*/*.rst linguist-documentation=false 5 | test/harness/wast.js linguist-vendored 6 | test/harness/testharness* linguist-vendored 7 | 8 | -------------------------------------------------------------------------------- /.github/workflows/ci-interpreter.yml: -------------------------------------------------------------------------------- 1 | name: CI for interpreter & tests 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | paths: [ .github/**, interpreter/**, test/** ] 7 | 8 | pull_request: 9 | branches: [ main ] 10 | paths: [ .github/**, interpreter/**, test/** ] 11 | 12 | # Allows you to run this workflow manually from the Actions tab 13 | workflow_dispatch: 14 | 15 | jobs: 16 | interpreter: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout repo 20 | uses: actions/checkout@v2 21 | - name: Setup OCaml 22 | uses: ocaml/setup-ocaml@v2 23 | with: 24 | ocaml-compiler: 4.14.x 25 | - name: Setup OCaml tools 26 | run: opam install --yes ocamlfind.1.9.5 js_of_ocaml.4.0.0 js_of_ocaml-ppx.4.0.0 27 | - name: Setup Node.js 28 | uses: actions/setup-node@v2 29 | with: 30 | node-version: 19.x 31 | - name: Build interpreter 32 | run: cd interpreter && opam exec make 33 | - name: Run tests 34 | # TODO: disable node.js run until it fully implements proposal 35 | # run: cd interpreter && opam exec make JS=node ci 36 | run: cd interpreter && opam exec make ci 37 | -------------------------------------------------------------------------------- /.github/workflows/mirror-to-master.yml: -------------------------------------------------------------------------------- 1 | name: Mirror main branch to master branch 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'main' 7 | 8 | jobs: 9 | mirror_job: 10 | runs-on: ubuntu-latest 11 | name: Mirror main branch to master branch 12 | steps: 13 | - name: Mirror branch 14 | uses: google/mirror-branch-action@v1.0 15 | with: 16 | github-token: ${{ secrets.GITHUB_TOKEN }} 17 | source: 'main' 18 | dest: 'master' 19 | -------------------------------------------------------------------------------- /.github/workflows/w3c-publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish to W3C TR space 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | paths: [ .github/**, document/** ] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | jobs: 12 | publish-to-w3c-TR: 13 | if: github.repository == 'WebAssembly/spec' 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout repo 17 | uses: actions/checkout@v2 18 | with: 19 | submodules: "recursive" 20 | - name: Setup Node.js 21 | uses: actions/setup-node@v3 22 | with: 23 | node-version: 16 24 | - name: Setup Bikeshed 25 | run: pip install bikeshed && bikeshed update 26 | - name: Setup TexLive 27 | run: sudo apt-get update -y && sudo apt-get install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended 28 | - name: Setup Sphinx 29 | run: pip install six && pip install sphinx==5.1.0 30 | - name: Publish all specs to their https://www.w3.org/TR/ URLs 31 | run: cd document && make -e WD-echidna-CI 32 | env: 33 | STATUS: --md-status=WD 34 | W3C_ECHIDNA_TOKEN_CORE: ${{ secrets.W3C_ECHIDNA_TOKEN_CORE }} 35 | W3C_ECHIDNA_TOKEN_JSAPI: ${{ secrets.W3C_ECHIDNA_TOKEN_JSAPI }} 36 | W3C_ECHIDNA_TOKEN_WEBAPI: ${{ secrets.W3C_ECHIDNA_TOKEN_WEBAPI }} 37 | YARN_ENABLE_IMMUTABLE_INSTALLS: false 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/*~ 2 | **/*.tmproj 3 | **/*.pyc 4 | **/_build 5 | **/_output 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "document/core/util/katex"] 2 | path = document/core/util/katex 3 | url = https://github.com/KaTeX/KaTeX.git 4 | -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to WebAssembly 2 | 3 | Interested in participating? Please follow 4 | [the same contributing guidelines as the design repository][]. 5 | 6 | [the same contributing guidelines as the design repository]: https://github.com/WebAssembly/design/blob/main/Contributing.md 7 | 8 | Also, please be sure to read [the README.md](README.md) for this repository. 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Please see the LICENSE file in each top-level directory for the terms applicable to that directory and its relative sub-directories. 2 | 3 | The relevant directories and licenses are: 4 | 5 | document/ - W3C Software and Document Notice and License 6 | interpreter/ - Apache License 2.0 7 | test/ - Apache License 2.0 8 | papers/ - Creative Commons Attribution 4.0 International License 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![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) 2 | [![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) 3 | 4 | # Function Reference Types Proposal for WebAssembly 5 | 6 | This repository is a clone of [github.com/WebAssembly/spec/](https://github.com/WebAssembly/spec/). 7 | It is meant for discussion, prototype specification and implementation of a proposal to add support for basic function reference types to WebAssembly. 8 | 9 | * See the [overview](proposals/function-references/Overview.md) for a summary of the proposal. 10 | 11 | * See the [modified spec](https://webassembly.github.io/function-references/core) for details. 12 | 13 | The repository is now based on the [bulk operations proposal](proposals/bulk-memory-operations/Overview.md) and includes all respective changes. 14 | 15 | Original README from upstream repository follows... 16 | 17 | # spec 18 | 19 | This repository holds a prototypical reference implementation for WebAssembly, 20 | which is currently serving as the official specification. Eventually, we expect 21 | to produce a specification either written in human-readable prose or in a formal 22 | specification language. 23 | 24 | It also holds the WebAssembly testsuite, which tests numerous aspects of 25 | conformance to the spec. 26 | 27 | View the work-in-progress spec at [webassembly.github.io/spec](https://webassembly.github.io/spec/). 28 | 29 | At this time, the contents of this repository are under development and known 30 | to be "incomplet and inkorrect". 31 | 32 | Participation is welcome. Discussions about new features, significant semantic 33 | changes, or any specification change likely to generate substantial discussion 34 | should take place in 35 | [the WebAssembly design repository](https://github.com/WebAssembly/design) 36 | first, so that this spec repository can remain focused. And please follow the 37 | [guidelines for contributing](Contributing.md). 38 | 39 | # citing 40 | 41 | For citing WebAssembly in LaTeX, use [this bibtex file](wasm-specs.bib). 42 | -------------------------------------------------------------------------------- /document/Makefile: -------------------------------------------------------------------------------- 1 | DIRS = js-api web-api core 2 | FILES = index.html 3 | BUILDDIR = _build 4 | TAR = tar 5 | 6 | # Global targets. 7 | 8 | .PHONY: all 9 | all: $(BUILDDIR) root $(DIRS) 10 | 11 | $(BUILDDIR): 12 | mkdir -p $@ 13 | 14 | .PHONY: deploy 15 | deploy: 16 | GIT_DEPLOY_DIR=$(BUILDDIR) bash deploy.sh 17 | 18 | .PHONY: publish 19 | publish: all deploy 20 | 21 | .PHONY: clean 22 | clean: $(DIRS:%=clean-%) 23 | rm -rf $(BUILDDIR) 24 | 25 | .PHONY: diff 26 | diff: $(DIRS:%=diff-%) 27 | 28 | # macOS: do “brew install tar” & run “make” as: TAR=gtar make -e WD-tar 29 | .PHONY: WD-tar 30 | WD-tar: 31 | for dir in $(DIRS); \ 32 | do STATUS=--md-status=WD TAR=$(TAR) $(MAKE) -e -C $$dir $@;\ 33 | done 34 | 35 | # macOS: do “brew install tar” & run “make” as: TAR=gtar make -e WD-echidna 36 | .PHONY: WD-echidna 37 | WD-echidna: 38 | for dir in $(DIRS); \ 39 | do $(MAKE) -e -C $$dir $@;\ 40 | done 41 | 42 | .PHONY: WD-echidna-CI 43 | WD-echidna-CI: 44 | for dir in $(DIRS); \ 45 | do $(MAKE) -e -C $$dir $@;\ 46 | done 47 | 48 | # Directory-specific targets. 49 | 50 | .PHONY: root 51 | root: $(BUILDDIR) 52 | touch $(BUILDDIR)/.nojekyll 53 | cp -f $(FILES) $(BUILDDIR)/ 54 | 55 | .PHONY: $(DIRS) 56 | $(DIRS): %: $(BUILDDIR) $(DIRS:%=build-%) $(DIRS:%=dir-%) 57 | 58 | .PHONY: $(DIRS:%=build-%) 59 | $(DIRS:%=build-%): build-%: 60 | (cd $(@:build-%=%); make BUILDDIR=$(BUILDDIR) all) 61 | 62 | .PHONY: $(DIRS:%=dir-%) 63 | $(DIRS:%=dir-%): dir-%: 64 | mkdir -p $(BUILDDIR)/$(@:dir-%=%) 65 | rm -rf $(BUILDDIR)/$(@:dir-%=%)/* 66 | cp -R $(@:dir-%=%)/$(BUILDDIR)/html/* $(BUILDDIR)/$(@:dir-%=%)/ 67 | 68 | .PHONY: $(DIRS:%=deploy-%) 69 | $(DIRS:%=deploy-%): deploy-%: 70 | GIT_DEPLOY_DIR=$(BUILDDIR) GIT_DEPLOY_SUBDIR=$(@:deploy-%=%) bash deploy.sh 71 | 72 | .PHONY: $(DIRS:%=publish-%) 73 | $(DIRS:%=publish-%): publish-%: % deploy-% 74 | 75 | .PHONY: $(DIRS:%=clean-%) 76 | $(DIRS:%=clean-%): clean-%: 77 | (cd $(@:clean-%=%); make BUILDDIR=$(BUILDDIR) clean) 78 | rm -rf $(BUILDDIR)/$(@:clean-%=%) 79 | 80 | .PHONY: $(DIRS:%=diff-%) 81 | $(DIRS:%=diff-%): diff-%: 82 | (cd $(@:diff-%=%); make BUILDDIR=$(BUILDDIR) diff) 83 | 84 | 85 | # Help. 86 | 87 | .PHONY: help 88 | help: 89 | @echo "Please use \`make ' where is one of" 90 | @echo " all to build all documents" 91 | @echo " publish to make all and push to gh-pages" 92 | @echo " to build a specific subdirectory" 93 | @echo " publish- to build and push a specific subdirectory" 94 | 95 | .PHONY: usage 96 | usage: help 97 | -------------------------------------------------------------------------------- /document/core/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | _static 3 | document/*.pyc 4 | -------------------------------------------------------------------------------- /document/core/LICENSE: -------------------------------------------------------------------------------- 1 | W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE 2 | 3 | This work is being provided by the copyright holders under the following 4 | license. 5 | 6 | 7 | LICENSE 8 | 9 | By obtaining and/or copying this work, you (the licensee) agree that you have 10 | read, understood, and will comply with the following terms and conditions. 11 | 12 | Permission to copy, modify, and distribute this work, with or without 13 | modification, for any purpose and without fee or royalty is hereby granted, 14 | provided that you include the following on ALL copies of the work or portions 15 | thereof, including modifications: 16 | 17 | * The full text of this NOTICE in a location viewable to users of the 18 | redistributed or derivative work. 19 | 20 | * Any pre-existing intellectual property disclaimers, notices, or terms and 21 | conditions. If none exist, the W3C Software and Document Short Notice 22 | (https://www.w3.org/Consortium/Legal/copyright-software-short-notice) should 23 | be included. 24 | 25 | * Notice of any changes or modifications, through a copyright statement on the 26 | new code or document such as "This software or document includes material 27 | copied from or derived from [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)." 28 | 29 | 30 | DISCLAIMERS 31 | 32 | THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS 33 | OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF 34 | MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE 35 | SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, 36 | TRADEMARKS OR OTHER RIGHTS. 37 | 38 | COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR 39 | CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT. 40 | 41 | The name and trademarks of copyright holders may NOT be used in advertising or 42 | publicity pertaining to the work without specific, written prior permission. 43 | Title to copyright in this work will at all times remain with copyright 44 | holders. 45 | 46 | 47 | NOTES 48 | 49 | This version: 50 | http://www.w3.org/Consortium/Legal/2015/copyright-software-and-document 51 | -------------------------------------------------------------------------------- /document/core/README.md: -------------------------------------------------------------------------------- 1 | # WebAssembly Core Specification 2 | 3 | This is the official WebAssembly "language" specification. 4 | 5 | It uses [Sphinx](http://www.sphinx-doc.org/). To install that: 6 | ``` 7 | pip install sphinx 8 | ``` 9 | To make HTML (result in `_build/html`): 10 | ``` 11 | make html 12 | ``` 13 | To make PDF (result in `_build/latex`, requires LaTeX): 14 | ``` 15 | make pdf 16 | ``` 17 | To make all: 18 | ``` 19 | make all 20 | ``` 21 | Finally, to make all and update webassembly.github.io/spec with it: 22 | ``` 23 | make publish 24 | ``` 25 | Please make sure to only use that once a change has approval. 26 | -------------------------------------------------------------------------------- /document/core/appendix/index-types.rst: -------------------------------------------------------------------------------- 1 | .. index:: type 2 | .. _index-type: 3 | 4 | Index of Types 5 | -------------- 6 | 7 | ======================================== =========================================== =============================================================================== 8 | Category Constructor Binary Opcode 9 | ======================================== =========================================== =============================================================================== 10 | :ref:`Type index ` :math:`x` (positive number as |Bs32| or |Bu32|) 11 | :ref:`Number type ` |I32| :math:`\hex{7F}` (-1 as |Bs7|) 12 | :ref:`Number type ` |I64| :math:`\hex{7E}` (-2 as |Bs7|) 13 | :ref:`Number type ` |F32| :math:`\hex{7D}` (-3 as |Bs7|) 14 | :ref:`Number type ` |F64| :math:`\hex{7C}` (-4 as |Bs7|) 15 | :ref:`Vector type ` |V128| :math:`\hex{7B}` (-5 as |Bs7|) 16 | (reserved) :math:`\hex{7A}` .. :math:`\hex{71}` 17 | :ref:`Heap type ` |FUNC| :math:`\hex{70}` (-16 as |Bs7|) 18 | :ref:`Heap type ` |EXTERN| :math:`\hex{6F}` (-17 as |Bs7|) 19 | (reserved) :math:`\hex{6E}` .. :math:`\hex{65}` 20 | :ref:`Reference type ` |REF| :math:`\hex{64}` (-28 as |Bs7|) 21 | :ref:`Reference type ` |REF| |NULL| :math:`\hex{63}` (-29 as |Bs7|) 22 | (reserved) :math:`\hex{62}` .. :math:`\hex{61}` 23 | :ref:`Function type ` :math:`[\valtype^\ast] \toF[\valtype^\ast]` :math:`\hex{60}` (-32 as |Bs7|) 24 | (reserved) :math:`\hex{5F}` .. :math:`\hex{41}` 25 | :ref:`Result type ` :math:`[\epsilon]` :math:`\hex{40}` (-64 as |Bs7|) 26 | :ref:`Table type ` :math:`\limits~\reftype` (none) 27 | :ref:`Memory type ` :math:`\limits` (none) 28 | :ref:`Global type ` :math:`\mut~\valtype` (none) 29 | ======================================== =========================================== =============================================================================== 30 | -------------------------------------------------------------------------------- /document/core/appendix/index.rst: -------------------------------------------------------------------------------- 1 | .. _appendix: 2 | 3 | Appendix 4 | ======== 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | embedding 10 | implementation 11 | properties 12 | algorithm 13 | custom 14 | changes 15 | 16 | .. only:: singlehtml 17 | 18 | .. toctree:: 19 | 20 | index-types 21 | index-instructions 22 | index-rules 23 | 24 | -------------------------------------------------------------------------------- /document/core/binary/index.rst: -------------------------------------------------------------------------------- 1 | .. _binary: 2 | 3 | Binary Format 4 | ============= 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | conventions 10 | values 11 | types 12 | instructions 13 | modules 14 | -------------------------------------------------------------------------------- /document/core/exec/index.rst: -------------------------------------------------------------------------------- 1 | .. _exec: 2 | 3 | Execution 4 | ========= 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | conventions 10 | runtime 11 | numerics 12 | types 13 | values 14 | instructions 15 | modules 16 | -------------------------------------------------------------------------------- /document/core/exec/types.rst: -------------------------------------------------------------------------------- 1 | .. index:: type, dynamic type 2 | .. _exec-type: 3 | 4 | Types 5 | ----- 6 | 7 | Execution has to check and compare :ref:`types ` in a few places, such as :ref:`executing ` |CALLINDIRECT| or :ref:`instantiating ` :ref:`modules `. 8 | 9 | It is an invariant of the semantics that all types occurring during execution are :ref:`closed `. 10 | 11 | .. note:: 12 | Runtime type checks generally involve types from multiple modules or types not defined by a module at all, such that module-local :ref:`type indices ` are not meaningful. 13 | 14 | 15 | 16 | .. index:: type index, defined type, type instantiation, module instance, dynamic type 17 | 18 | .. _type-inst: 19 | 20 | Instantiation 21 | ~~~~~~~~~~~~~ 22 | 23 | Any form of :ref:`type ` can be *instantiated* into a :ref:`closed ` type inside a :ref:`module instance ` by :ref:`substituting ` each :ref:`type index ` :math:`x` occurring in it with the corresponding :ref:`defined type ` :math:`\moduleinst.\MITYPES[x]`. 24 | 25 | .. math:: 26 | \insttype_{\moduleinst}(t) = t[\subst \moduleinst.\MITYPES] 27 | -------------------------------------------------------------------------------- /document/core/index.bs: -------------------------------------------------------------------------------- 1 | 17 | 18 |
19 | {
20 |   "WEBASSEMBLY": {
21 |     "href": "https://webassembly.github.io/spec/",
22 |     "title": "WebAssembly Specification",
23 |     "publisher": "W3C WebAssembly Community Group",
24 |     "status": "Draft"
25 |   }
26 | }
27 | 
28 | 29 |
30 | path: _build/bikeshed_singlehtml/index_fixed.html
31 | 
32 | -------------------------------------------------------------------------------- /document/core/index.rst: -------------------------------------------------------------------------------- 1 | WebAssembly Specification 2 | ========================= 3 | 4 | .. only:: html 5 | 6 | | Release |release| 7 | 8 | | Editor: Andreas Rossberg 9 | 10 | | Latest Draft: |WasmDraft| 11 | | Issue Tracker: |WasmIssues| 12 | 13 | .. toctree:: 14 | :maxdepth: 2 15 | 16 | intro/index 17 | syntax/index 18 | valid/index 19 | exec/index 20 | binary/index 21 | text/index 22 | appendix/index 23 | 24 | .. only:: latex 25 | 26 | .. toctree:: 27 | 28 | appendix/index-types 29 | appendix/index-instructions 30 | appendix/index-rules 31 | 32 | .. 33 | Only include these links when using (multi-page) html builder. 34 | (The singlepage html builder is called builder_singlehtml.) 35 | 36 | .. only:: builder_html 37 | 38 | * :ref:`index-type` 39 | * :ref:`index-instr` 40 | * :ref:`index-rules` 41 | 42 | * :ref:`genindex` 43 | -------------------------------------------------------------------------------- /document/core/intro/index.rst: -------------------------------------------------------------------------------- 1 | .. _intro: 2 | 3 | Introduction 4 | ============ 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | introduction 10 | overview 11 | -------------------------------------------------------------------------------- /document/core/static/custom.css: -------------------------------------------------------------------------------- 1 | a { 2 | color: #004BAB; 3 | text-decoration: none; 4 | } 5 | 6 | a.reference { 7 | border-bottom: none; 8 | } 9 | 10 | a.reference:hover { 11 | border-bottom: 1px dotted #004BAB; 12 | } 13 | 14 | body { 15 | font-size: 15px; 16 | } 17 | 18 | div.document { width: 1000px; } 19 | div.bodywrapper { margin: 0 0 0 200px; } 20 | div.body { padding: 0 10px 0 10px; } 21 | div.footer { width: 1000px; } 22 | 23 | div.body h1 { font-size: 200%; } 24 | div.body h2 { font-size: 150%; } 25 | div.body h3 { font-size: 120%; } 26 | div.body h4 { font-size: 110%; } 27 | 28 | div.note { 29 | border: 0px; 30 | font-size: 90%; 31 | background-color: #F6F8FF; 32 | } 33 | 34 | div.admonition { 35 | padding: 10px; 36 | } 37 | 38 | div.admonition p.admonition-title { 39 | margin: 0px 0px 0px 0px; 40 | font-size: 100%; 41 | font-weight: bold; 42 | } 43 | 44 | div.math { 45 | background-color: #F0F0F0; 46 | padding: 3px 0 3px 0; 47 | overflow-x: auto; 48 | overflow-y: hidden; 49 | } 50 | 51 | div.relations { 52 | display: block; 53 | } 54 | 55 | div.sphinxsidebar { 56 | z-index: 1; 57 | background: #FFF; 58 | margin-top: -30px; 59 | font-size: 13px; 60 | width: 200px; 61 | height: 100%; 62 | } 63 | 64 | div.sphinxsidebarwrapper p.logo { 65 | padding: 30px 40px 10px 0px; 66 | } 67 | 68 | div.sphinxsidebar h3 { 69 | font-size: 0px; 70 | } 71 | 72 | div.sphinxsidebar a { 73 | border-bottom: 0px; 74 | } 75 | 76 | div.sphinxsidebar a:hover { 77 | border-bottom: 1px dotted; 78 | } 79 | -------------------------------------------------------------------------------- /document/core/static/webassembly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/function-references/74d2ec81d15efd3c0f2fba46a023f376101d8e46/document/core/static/webassembly.png -------------------------------------------------------------------------------- /document/core/syntax/index.rst: -------------------------------------------------------------------------------- 1 | .. _syntax: 2 | 3 | Structure 4 | ========= 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | conventions 10 | values 11 | types 12 | instructions 13 | modules 14 | -------------------------------------------------------------------------------- /document/core/text/index.rst: -------------------------------------------------------------------------------- 1 | .. _text: 2 | 3 | Text Format 4 | =========== 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | conventions 10 | lexical 11 | values 12 | types 13 | instructions 14 | modules 15 | -------------------------------------------------------------------------------- /document/core/util/README.htmldiff.pl: -------------------------------------------------------------------------------- 1 | This file is a copy of the HTML diff script found here: 2 | https://dev.w3.org/cvsweb/2009/htmldiff/ 3 | -------------------------------------------------------------------------------- /document/core/util/bikeshed/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Sphinx configuration for bikeshed builds (make bikeshed). 4 | # This imports the main document/core/conf.py, then overwrites certain config 5 | # values for the bikeshed build. 6 | 7 | import os 8 | import sys 9 | original_pwd = os.path.abspath('../..') 10 | # Change sys.path so that we can find the main 'conf.py'. 11 | sys.path.insert(0, original_pwd) 12 | from conf import * 13 | main_conf_pwd = pwd 14 | 15 | # Now that we have imported all the settings, we need to overwrite some of 16 | # them. 17 | 18 | # The first is `pwd`, we want to reset it to document/core, because rst_prolog 19 | # below depends on this to find macros.def. 20 | pwd = original_pwd 21 | 22 | # The bikeshed build requires the mathdefbs extension. 23 | extensions[extensions.index('util.mathdef')] = 'util.mathdefbs' 24 | 25 | # Overwrite html themes and configurations. 26 | html_theme = 'classic' 27 | html_permalinks = False 28 | html_theme_options = { 29 | 'nosidebar': True, 30 | } 31 | html_show_copyright = False 32 | 33 | # Overwrite the prolog to make sure the include directive has the correct path. 34 | 35 | main_macros_def = "/" + main_conf_pwd + "/util/macros.def" 36 | # If we hit this assertion, the configuration files probably moved, or files 37 | # are renamed, and we have to update rst_prolog accordingly. 38 | assert(main_macros_def in rst_prolog) 39 | rst_prolog = rst_prolog.replace(main_macros_def, "/" + pwd + "/util/macros.def") 40 | 41 | del mathjax3_config 42 | -------------------------------------------------------------------------------- /document/core/util/bikeshed_fixup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: latin-1 -*- 3 | 4 | import os 5 | import sys 6 | import re 7 | 8 | 9 | SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) 10 | 11 | 12 | def Main(): 13 | data = open(sys.argv[1]).read() 14 | 15 | # Make bikeshed happy 16 | # Apparently it can't handle empty line before DOCTYPE comment 17 | data = data.replace('\n 19 | data = data.replace('
', '\n
')
20 | 
21 |   # Don't add more than 3 levels to TOC.
22 |   data = data.replace('
', '
') 23 | 24 | # TODO(bradnelson/tabatkins): Fix when bikeshed can do letters. 25 | # Don't number the Appendix. 26 | data = data.replace( 27 | '

Appendix

', 28 | '

A Appendix

') 29 | number = 1 30 | for section in [ 31 | 'Embedding', 32 | 'Implementation Limitations', 33 | 'Validation Algorithm', 34 | 'Custom Sections', 35 | 'Soundness', 36 | 'Index of Types', 37 | 'Index of Instructions', 38 | 'Index of Semantic Rules']: 39 | data = data.replace( 40 | '

' + section + '

', 41 | '

A.' + str(number) + ' ' + section + '

') 42 | number += 1 43 | 44 | 45 | # Drop spurious navigation. 46 | data = data.replace( 47 | """ 48 | """, '') 55 | 56 | # Use bikeshed biblio references for unicode and IEEE754 57 | data = data.replace( 58 | """Unicode""", 59 | "[[!UNICODE]]" 60 | ) 61 | 62 | data = data.replace( 63 | """IEEE 754""", 64 | "[[!IEEE-754-2019]]" 65 | ) 66 | 67 | # Fix this problem that causes an element to be generated in the output 68 | # as a child of another element, and for which the HTML validator reports 69 | # an error — which in turn causes the W3C pubrules checker to refuse to 70 | # autopublish the resulting bikeshed output. 71 | data = data.replace( 72 | """\href{#binary-sint}{\href{#syntax-int}""", 73 | """{\href{#syntax-int}""") 74 | 75 | # Strip the entire element from the the sphinx output — because it 76 | # contains several ,