Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Dec 9, 2023
2 parents 5d65049 + ca328fc commit 3eecdce
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci-interpreter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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.12.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
run: cd interpreter && opam exec make JS=node ci
101 changes: 101 additions & 0 deletions .github/workflows/ci-spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
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 }}
18 changes: 18 additions & 0 deletions .github/workflows/mirror-to-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Mirror main branch to master branch

on:
push:
branches:
- 'main'

jobs:
mirror_job:
runs-on: ubuntu-latest
name: Mirror main branch to master branch
steps:
- name: Mirror branch
uses: google/mirror-branch-action@v1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
source: 'main'
dest: 'master'
9 changes: 8 additions & 1 deletion document/js-api/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,15 @@ interface Instance {
<h3 id="memories">Memories</h3>

<pre class="idl">
enum MemoryIndexType {
"i32",
"i64",
};

dictionary MemoryDescriptor {
required [EnforceRange] unsigned long initial;
[EnforceRange] unsigned long maximum;
MemoryIndexType index;
};

[LegacyNamespace=WebAssembly, Exposed=(Window,Worker,Worklet)]
Expand Down Expand Up @@ -677,7 +683,8 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
1. Let |initial| be |descriptor|["initial"].
1. If |descriptor|["maximum"] [=map/exists=], let |maximum| be |descriptor|["maximum"]; otherwise, let |maximum| be empty.
1. If |maximum| is not empty and |maximum| &lt; |initial|, throw a {{RangeError}} exception.
1. Let |memtype| be { min |initial|, max |maximum| }.
1. If |descriptior|["index"] [=map/exists=], let |index| be |descriptor|["index"]; otherwise, let |index| be "i32".
1. Let |memtype| be { min |initial|, max |maximum|, index |index| }.
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
1. Let (|store|, |memaddr|) be [=mem_alloc=](|store|, |memtype|). If allocation fails, throw a {{RangeError}} exception.
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
Expand Down
4 changes: 2 additions & 2 deletions proposals/memory64/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ have to support 32-bit memory addresses in their ABI.
| 0x03 n:u32 m:u32 ⇒ i32, {min n, max m}, 1 ;; from threads proposal
| 0x04 n:u64 ⇒ i64, {min n, max ϵ}, 0
| 0x05 n:u64 m:u64 ⇒ i64, {min n, max m}, 0
| 0x06 n:u32 ⇒ i64, {min n, max ϵ}, 1 ;; from threads proposal
| 0x07 n:u32 m:u32 ⇒ i64, {min n, max m}, 1 ;; from threads proposal
| 0x06 n:u64 ⇒ i64, {min n, max ϵ}, 1 ;; from threads proposal
| 0x07 n:u64 m:u64 ⇒ i64, {min n, max m}, 1 ;; from threads proposal
```

* The [memory type][binary memtype] structure is extended to use this limits
Expand Down
33 changes: 33 additions & 0 deletions test/core/binary-leb128.wast
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,39 @@
)
"integer too large"
)
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\04\00" ;; Memory section (flags: i64)
"\0a\13\01" ;; Code section
;; function 0
"\11\00" ;; local type count
"\42\00" ;; i64.const 0
"\28" ;; i32.load
"\02" ;; alignment 2
"\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; offset 2^64 - 1
"\1a" ;; drop
"\0b" ;; end
)
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\04\00" ;; Memory section (flags: i64)
"\0a\13\01" ;; Code section
;; function 0
"\11\00" ;; local type count
"\42\00" ;; i64.const 0
"\28" ;; i32.load
"\02" ;; alignment 2
"\ff\ff\ff\ff\ff\ff\ff\ff\ff\02" ;; offset 2^64 (one unused bit set)
"\1a" ;; drop
"\0b" ;; end
)
"integer too large"
)

;; Signed LEB128s sign-extend
(assert_malformed
Expand Down
7 changes: 6 additions & 1 deletion test/js-api/memory/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ function assert_ArrayBuffer(actual, { size=0, shared=false, detached=false }, me
assert_equals(Object.isExtensible(actual), !shared, "buffer extensibility");
}

function assert_Memory(memory, { size=0, shared=false }) {
function assert_Memory(memory, { size=0, shared=false, index="u32" }) {
assert_equals(Object.getPrototypeOf(memory), WebAssembly.Memory.prototype,
"prototype");
assert_true(Object.isExtensible(memory), "extensible");

// https://github.com/WebAssembly/spec/issues/840
assert_equals(memory.buffer, memory.buffer, "buffer should be idempotent");
assert_ArrayBuffer(memory.buffer, { size, shared });

// this depends on js-types proposal implementation
if (typeof memory.type == "function") {
assert_equals(memory.type().index, index, "memory index");
}
}
24 changes: 24 additions & 0 deletions test/js-api/memory/constructor.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ test(() => {
case "initial":
case "maximum":
return 0;
case "index":
return "i32";
default:
return undefined;
}
Expand Down Expand Up @@ -137,3 +139,25 @@ test(() => {
const memory = new WebAssembly.Memory(argument, {});
assert_Memory(memory, { "size": 0 });
}, "Stray argument");

test(() => {
const argument = { "initial": 1 };
const memory = new WebAssembly.Memory(argument);
assert_Memory(memory, { "size": 1, "index": "i32" });
}, "Memory with index parameter omitted");

test(() => {
const argument = { "initial": 1, "index": "i32" };
const memory = new WebAssembly.Memory(argument);
assert_Memory(memory, { "size": 1, "index": "i32" });
}, "Memory with i32 index constructor");

test(() => {
const argument = { "initial": 1, "index": "i64" };
const memory = new WebAssembly.Memory(argument);
assert_Memory(memory, { "size": 1, "index": "i64" });
}, "Memory with i64 index constructor");

test(() => {
assert_throws_js(TypeError, () => new WebAssembly.Memory({ "initial": 1, "index": "none" }));
}, "Unknown memory index");

0 comments on commit 3eecdce

Please sign in to comment.