From 08d7ccb35e1eb007bf5677692c81a9f62f0cffe8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 22:04:42 +0000 Subject: [PATCH 01/16] Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 4.1.7. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v2...v4.1.7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/workflows/ci-spec.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-spec.yml b/.github/workflows/ci-spec.yml index e88a224d61..6caf511eba 100644 --- a/.github/workflows/ci-spec.yml +++ b/.github/workflows/ci-spec.yml @@ -79,17 +79,17 @@ jobs: - name: Create output directory run: mkdir _output && cp document/index.html _output/index.html - name: Download core spec artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4.1.7 with: name: core-rendered path: _output/core - name: Download JS API spec artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4.1.7 with: name: js-api-rendered path: _output/js-api - name: Download Web API spec artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4.1.7 with: name: web-api-rendered path: _output/web-api From 6e2dfb3b5450571c251aae256880ddc1102ff88a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 22:05:05 +0000 Subject: [PATCH 02/16] Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 4.1.7. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v2...v4.1.7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/workflows/ci-spec.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-spec.yml b/.github/workflows/ci-spec.yml index e88a224d61..6caf511eba 100644 --- a/.github/workflows/ci-spec.yml +++ b/.github/workflows/ci-spec.yml @@ -79,17 +79,17 @@ jobs: - name: Create output directory run: mkdir _output && cp document/index.html _output/index.html - name: Download core spec artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4.1.7 with: name: core-rendered path: _output/core - name: Download JS API spec artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4.1.7 with: name: js-api-rendered path: _output/js-api - name: Download Web API spec artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4.1.7 with: name: web-api-rendered path: _output/web-api From 6cdb72f36a68eb126b5316f467e9cf25cdda9015 Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Wed, 4 Sep 2024 07:13:01 +0200 Subject: [PATCH 03/16] Use consistent upload-artifact --- .github/workflows/ci-spec.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-spec.yml b/.github/workflows/ci-spec.yml index 6caf511eba..1c562cbecb 100644 --- a/.github/workflows/ci-spec.yml +++ b/.github/workflows/ci-spec.yml @@ -35,7 +35,7 @@ jobs: - name: Run Bikeshed run: cd document/core && make bikeshed - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: core-rendered path: document/core/_build/html @@ -50,7 +50,7 @@ jobs: - name: Run Bikeshed run: bikeshed spec "document/js-api/index.bs" "document/js-api/index.html" - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: js-api-rendered path: document/js-api/index.html @@ -79,17 +79,17 @@ jobs: - name: Create output directory run: mkdir _output && cp document/index.html _output/index.html - name: Download core spec artifact - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4 with: name: core-rendered path: _output/core - name: Download JS API spec artifact - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4 with: name: js-api-rendered path: _output/js-api - name: Download Web API spec artifact - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4 with: name: web-api-rendered path: _output/web-api From 3370cfccda79d1147b8518b79fe8eff2c9d8e37b Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Wed, 4 Sep 2024 07:59:58 +0200 Subject: [PATCH 04/16] Missed one --- .github/workflows/ci-spec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-spec.yml b/.github/workflows/ci-spec.yml index 1c562cbecb..a3b4dd875e 100644 --- a/.github/workflows/ci-spec.yml +++ b/.github/workflows/ci-spec.yml @@ -65,7 +65,7 @@ jobs: - name: Run Bikeshed run: bikeshed spec "document/web-api/index.bs" "document/web-api/index.html" - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: web-api-rendered path: document/web-api/index.html From 59174d534dd9422645d03da266d8f2b3a8b21e33 Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Wed, 4 Sep 2024 08:33:09 +0200 Subject: [PATCH 05/16] Update ci-spec.yml --- .github/workflows/ci-spec.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-spec.yml b/.github/workflows/ci-spec.yml index 6caf511eba..a3b4dd875e 100644 --- a/.github/workflows/ci-spec.yml +++ b/.github/workflows/ci-spec.yml @@ -35,7 +35,7 @@ jobs: - name: Run Bikeshed run: cd document/core && make bikeshed - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: core-rendered path: document/core/_build/html @@ -50,7 +50,7 @@ jobs: - name: Run Bikeshed run: bikeshed spec "document/js-api/index.bs" "document/js-api/index.html" - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: js-api-rendered path: document/js-api/index.html @@ -65,7 +65,7 @@ jobs: - name: Run Bikeshed run: bikeshed spec "document/web-api/index.bs" "document/web-api/index.html" - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: web-api-rendered path: document/web-api/index.html @@ -79,17 +79,17 @@ jobs: - name: Create output directory run: mkdir _output && cp document/index.html _output/index.html - name: Download core spec artifact - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4 with: name: core-rendered path: _output/core - name: Download JS API spec artifact - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4 with: name: js-api-rendered path: _output/js-api - name: Download Web API spec artifact - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4 with: name: web-api-rendered path: _output/web-api From d29854b17bb949fcf52453b40761e157208f43e4 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 19 Sep 2024 13:07:55 -0700 Subject: [PATCH 06/16] Fix typing of `array.new` in the index of instructions --- document/core/appendix/index-instructions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/document/core/appendix/index-instructions.py b/document/core/appendix/index-instructions.py index 5cf52ad9d6..2be87918c6 100755 --- a/document/core/appendix/index-instructions.py +++ b/document/core/appendix/index-instructions.py @@ -325,7 +325,7 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat Instruction(r'\STRUCTGETS~x~y', r'\hex{FB}~\hex{03}', r'[(\REF~\NULL~x)] \to [\I32]', r'valid-struct.get', r'exec-struct.get'), Instruction(r'\STRUCTGETU~x~y', r'\hex{FB}~\hex{04}', r'[(\REF~\NULL~x)] \to [\I32]', r'valid-struct.get', r'exec-struct.get'), Instruction(r'\STRUCTSET~x~y', r'\hex{FB}~\hex{05}', r'[(\REF~\NULL~x)~t] \to []', r'valid-struct.set', r'exec-struct.set'), - Instruction(r'\ARRAYNEW~x', r'\hex{FB}~\hex{06}', r'[t] \to [(\REF~x)]', r'valid-array.new', r'exec-array.new'), + Instruction(r'\ARRAYNEW~x', r'\hex{FB}~\hex{06}', r'[t~\I32] \to [(\REF~x)]', r'valid-array.new', r'exec-array.new'), Instruction(r'\ARRAYNEWDEFAULT~x', r'\hex{FB}~\hex{07}', r'[\I32] \to [(\REF~x)]', r'valid-array.new', r'exec-array.new'), Instruction(r'\ARRAYNEWFIXED~x~n', r'\hex{FB}~\hex{08}', r'[t^n] \to [(\REF~x)]', r'valid-array.new_fixed', r'exec-array.new_fixed'), Instruction(r'\ARRAYNEWDATA~x~y', r'\hex{FB}~\hex{09}', r'[\I32~\I32] \to [(\REF~x)]', r'valid-array.new_data', r'exec-array.new_data'), From 8971797b0bd3cdf89d6e8e3d8f67551a9792c064 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Fri, 27 Sep 2024 13:59:53 -0700 Subject: [PATCH 07/16] Expand tests for `array.new_data` Noticed that the existing tests didn't exercise out-of-bounds indexing of the data segment, so I added a test for that. At the same time, since I was already creating a dedicated `.wast` file for testing `array.new_data`, I also added a few general tests to round the file out. Some of these might technically duplicate things that already happen to be tested in `array.wast`, but I think that's probably fine, and that it is good to have dedicated tests in this new file. I can remove them if we'd rather not have these potential-duplicate tests. --- test/core/gc/array_new_data.wast | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test/core/gc/array_new_data.wast diff --git a/test/core/gc/array_new_data.wast b/test/core/gc/array_new_data.wast new file mode 100644 index 0000000000..397a86e35b --- /dev/null +++ b/test/core/gc/array_new_data.wast @@ -0,0 +1,50 @@ +(module + (type $arr (array (mut i8))) + + (data $d "abcd") + + (func (export "array-new-data") (param i32 i32) (result (ref $arr)) + (array.new_data $arr $d (local.get 0) (local.get 1)) + ) +) + +;; In-bounds data segment accesses. +(assert_return (invoke "array-new-data" (i32.const 0) (i32.const 0)) (ref.array)) +(assert_return (invoke "array-new-data" (i32.const 0) (i32.const 4)) (ref.array)) +(assert_return (invoke "array-new-data" (i32.const 1) (i32.const 2)) (ref.array)) +(assert_return (invoke "array-new-data" (i32.const 4) (i32.const 0)) (ref.array)) + +;; Out-of-bounds data segment accesses. +(assert_trap (invoke "array-new-data" (i32.const 0) (i32.const 5)) "out of bounds memory access") +(assert_trap (invoke "array-new-data" (i32.const 5) (i32.const 0)) "out of bounds memory access") + +(module + (type $arr (array (mut i8))) + + (data $d "\aa\bb\cc\dd") + + (func (export "array-new-data-contents") (result i32 i32) + (local (ref null $arr)) + (local.set 0 (array.new_data $arr $d (i32.const 1) (i32.const 2))) + (array.get_u $arr (local.get 0) (i32.const 0)) + (array.get_u $arr (local.get 0) (i32.const 1)) + ) +) + +;; Array is initialized with the correct contents. +(assert_return (invoke "array-new-data-contents") (i32.const 0xbb) (i32.const 0xcc)) + +(module + (type $arr (array (mut i32))) + + (data $d "\aa\bb\cc\dd") + + (func (export "array-new-data-little-endian") (result i32) + (array.get $arr + (array.new_data $arr $d (i32.const 0) (i32.const 1)) + (i32.const 0)) + ) +) + +;; Data segments are interpreted as little-endian. +(assert_return (invoke "array-new-data-little-endian") (i32.const 0xddccbbaa)) From f713000271658a7a52d34da17032f0a27b698969 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Sat, 28 Sep 2024 02:01:29 -0700 Subject: [PATCH 08/16] Remove nullability of local --- test/core/gc/array_new_data.wast | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/gc/array_new_data.wast b/test/core/gc/array_new_data.wast index 397a86e35b..f55c28bf66 100644 --- a/test/core/gc/array_new_data.wast +++ b/test/core/gc/array_new_data.wast @@ -24,7 +24,7 @@ (data $d "\aa\bb\cc\dd") (func (export "array-new-data-contents") (result i32 i32) - (local (ref null $arr)) + (local (ref $arr)) (local.set 0 (array.new_data $arr $d (i32.const 1) (i32.const 2))) (array.get_u $arr (local.get 0) (i32.const 0)) (array.get_u $arr (local.get 0) (i32.const 1)) From 4c1061994fd2ca292d65d222ddce3d744383de04 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Sat, 28 Sep 2024 02:06:07 -0700 Subject: [PATCH 09/16] Add a couple more out-of-bounds data segment cases --- test/core/gc/array_new_data.wast | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/core/gc/array_new_data.wast b/test/core/gc/array_new_data.wast index f55c28bf66..da4865cf1d 100644 --- a/test/core/gc/array_new_data.wast +++ b/test/core/gc/array_new_data.wast @@ -17,6 +17,9 @@ ;; Out-of-bounds data segment accesses. (assert_trap (invoke "array-new-data" (i32.const 0) (i32.const 5)) "out of bounds memory access") (assert_trap (invoke "array-new-data" (i32.const 5) (i32.const 0)) "out of bounds memory access") +(assert_trap (invoke "array-new-data" (i32.const 1) (i32.const 4)) "out of bounds memory access") +(assert_trap (invoke "array-new-data" (i32.const 4) (i32.const 1)) "out of bounds memory access") + (module (type $arr (array (mut i8))) From f846dd190d6b1965fcef66772516b11f9329b0c6 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Sat, 28 Sep 2024 02:06:39 -0700 Subject: [PATCH 10/16] Add an unualigned data segment access test for `array.new_data` --- test/core/gc/array_new_data.wast | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/core/gc/array_new_data.wast b/test/core/gc/array_new_data.wast index da4865cf1d..2af894c169 100644 --- a/test/core/gc/array_new_data.wast +++ b/test/core/gc/array_new_data.wast @@ -51,3 +51,18 @@ ;; Data segments are interpreted as little-endian. (assert_return (invoke "array-new-data-little-endian") (i32.const 0xddccbbaa)) + +(module + (type $arr (array (mut i16))) + + (data $d "\00\11\22") + + (func (export "array-new-data-unaligned") (result i32) + (array.get_u $arr + (array.new_data $arr $d (i32.const 1) (i32.const 1)) + (i32.const 0)) + ) +) + +;; Data inside the segment doesn't need to be aligned to the element size. +(assert_return (invoke "array-new-data-unaligned") (i32.const 0x2211)) From b889c6359ccda4637df518400a7f6754e55673f6 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Sat, 28 Sep 2024 13:52:46 -0700 Subject: [PATCH 11/16] Test out-of-bounds element segment indexing for `array.new_elem` Similar to https://github.com/WebAssembly/gc/pull/562 but for `array.new_elem`. I opted to exercise both expression-style elements and the old MVP-style function-index elements, as they have slightly different representations in Wasmtime and that means we end up doing the indexing in two different code paths depending on which type of element segment we have. Figured that other engines might have similar code paths so it's good to test both. --- test/core/gc/array_new_elem.wast | 103 +++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 test/core/gc/array_new_elem.wast diff --git a/test/core/gc/array_new_elem.wast b/test/core/gc/array_new_elem.wast new file mode 100644 index 0000000000..d71d981d63 --- /dev/null +++ b/test/core/gc/array_new_elem.wast @@ -0,0 +1,103 @@ +;;;; Expression-style element segments. + +(module + (type $arr (array i31ref)) + + (elem $e i31ref + (ref.i31 (i32.const 0xaa)) + (ref.i31 (i32.const 0xbb)) + (ref.i31 (i32.const 0xcc)) + (ref.i31 (i32.const 0xdd))) + + (func (export "array-new-elem") (param i32 i32) (result (ref $arr)) + (array.new_elem $arr $e (local.get 0) (local.get 1)) + ) +) + +;; In-bounds element segment accesses. +(assert_return (invoke "array-new-elem" (i32.const 0) (i32.const 0)) (ref.array)) +(assert_return (invoke "array-new-elem" (i32.const 0) (i32.const 4)) (ref.array)) +(assert_return (invoke "array-new-elem" (i32.const 1) (i32.const 2)) (ref.array)) +(assert_return (invoke "array-new-elem" (i32.const 4) (i32.const 0)) (ref.array)) + +;; Out-of-bounds element segment accesses. +(assert_trap (invoke "array-new-elem" (i32.const 0) (i32.const 5)) "out of bounds table access") +(assert_trap (invoke "array-new-elem" (i32.const 5) (i32.const 0)) "out of bounds table access") +(assert_trap (invoke "array-new-elem" (i32.const 1) (i32.const 4)) "out of bounds table access") +(assert_trap (invoke "array-new-elem" (i32.const 4) (i32.const 1)) "out of bounds table access") + +(module + (type $arr (array i31ref)) + + (elem $e i31ref + (ref.i31 (i32.const 0xaa)) + (ref.i31 (i32.const 0xbb)) + (ref.i31 (i32.const 0xcc)) + (ref.i31 (i32.const 0xdd))) + + (func (export "array-new-elem-contents") (result i32 i32) + (local (ref $arr)) + (local.set 0 (array.new_elem $arr $e (i32.const 1) (i32.const 2))) + (i31.get_u (array.get $arr (local.get 0) (i32.const 0))) + (i31.get_u (array.get $arr (local.get 0) (i32.const 1))) + ) +) + +;; Array is initialized with the correct contents. +(assert_return (invoke "array-new-elem-contents") (i32.const 0xbb) (i32.const 0xcc)) + +;;;; MVP-style function-index segments. + +(module + (type $arr (array funcref)) + + (elem $e func $aa $bb $cc $dd) + (func $aa (result i32) (i32.const 0xaa)) + (func $bb (result i32) (i32.const 0xbb)) + (func $cc (result i32) (i32.const 0xcc)) + (func $dd (result i32) (i32.const 0xdd)) + + (func (export "array-new-elem") (param i32 i32) (result (ref $arr)) + (array.new_elem $arr $e (local.get 0) (local.get 1)) + ) +) + +;; In-bounds element segment accesses. +(assert_return (invoke "array-new-elem" (i32.const 0) (i32.const 0)) (ref.array)) +(assert_return (invoke "array-new-elem" (i32.const 0) (i32.const 4)) (ref.array)) +(assert_return (invoke "array-new-elem" (i32.const 1) (i32.const 2)) (ref.array)) +(assert_return (invoke "array-new-elem" (i32.const 4) (i32.const 0)) (ref.array)) + +;; Out-of-bounds element segment accesses. +(assert_trap (invoke "array-new-elem" (i32.const 0) (i32.const 5)) "out of bounds table access") +(assert_trap (invoke "array-new-elem" (i32.const 5) (i32.const 0)) "out of bounds table access") +(assert_trap (invoke "array-new-elem" (i32.const 1) (i32.const 4)) "out of bounds table access") +(assert_trap (invoke "array-new-elem" (i32.const 4) (i32.const 1)) "out of bounds table access") + +(module + (type $f (func (result i32))) + (type $arr (array funcref)) + + (elem $e func $aa $bb $cc $dd) + (func $aa (result i32) (i32.const 0xaa)) + (func $bb (result i32) (i32.const 0xbb)) + (func $cc (result i32) (i32.const 0xcc)) + (func $dd (result i32) (i32.const 0xdd)) + + (table $t 2 2 funcref) + + (func (export "array-new-elem-contents") (result i32 i32) + (local (ref $arr)) + (local.set 0 (array.new_elem $arr $e (i32.const 1) (i32.const 2))) + + (table.set $t (i32.const 0) (array.get $arr (local.get 0) (i32.const 0))) + (table.set $t (i32.const 1) (array.get $arr (local.get 0) (i32.const 1))) + + (call_indirect (type $f) (i32.const 0)) + (call_indirect (type $f) (i32.const 1)) + + ) +) + +;; Array is initialized with the correct contents. +(assert_return (invoke "array-new-elem-contents") (i32.const 0xbb) (i32.const 0xcc)) From 1f803e13b7e6814fe4f2c02cf2feea2bbac377f9 Mon Sep 17 00:00:00 2001 From: evilg Date: Fri, 25 Oct 2024 15:41:07 -0400 Subject: [PATCH 12/16] Fix test copy/paste typo (#566) --- test/core/gc/i31.wast | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/gc/i31.wast b/test/core/gc/i31.wast index 7485650454..6309e72b65 100644 --- a/test/core/gc/i31.wast +++ b/test/core/gc/i31.wast @@ -14,7 +14,7 @@ (i31.get_u (ref.null i31)) ) (func (export "get_s-null") (result i32) - (i31.get_u (ref.null i31)) + (i31.get_s (ref.null i31)) ) (global $i (ref i31) (ref.i31 (i32.const 2))) From 88463e822fafdf80f33b9eb84f0c489bd5940cf5 Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Thu, 31 Oct 2024 09:06:04 +0100 Subject: [PATCH 13/16] Fix direction of subtype check for call_indirect --- document/core/exec/instructions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/document/core/exec/instructions.rst b/document/core/exec/instructions.rst index 9412997703..894785ca31 100644 --- a/document/core/exec/instructions.rst +++ b/document/core/exec/instructions.rst @@ -4368,7 +4368,7 @@ Control Instructions \begin{array}[t]{@{}r@{~}l@{}} (\iff & S.\STABLES[F.\AMODULE.\MITABLES[x]].\TIELEM[i] = \REFFUNCADDR~a \\ \wedge & S.\SFUNCS[a] = f \\ - \wedge & S \vdashdeftypematch F.\AMODULE.\MITYPES[y] \matchesdeftype f.\FITYPE) + \wedge & S \vdashdeftypematch f.\FITYPE \matchesdeftype F.\AMODULE.\MITYPES[y]) \end{array} \\[1ex] \begin{array}{lcl@{\qquad}l} From 64f0f3a6573e4e6dfd1c661690456b73def6d25c Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 5 Dec 2024 15:03:16 -0800 Subject: [PATCH 14/16] Add some tests for invalid subtyping due to non-matching field types (#573) Specifically around the requirements that both field types have the same mutability and that the storage type must be exactly the same when the field type is mutable. --- test/core/gc/type-subtyping-invalid.wast | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/core/gc/type-subtyping-invalid.wast diff --git a/test/core/gc/type-subtyping-invalid.wast b/test/core/gc/type-subtyping-invalid.wast new file mode 100644 index 0000000000..d0442e2475 --- /dev/null +++ b/test/core/gc/type-subtyping-invalid.wast @@ -0,0 +1,37 @@ +(assert_invalid + (module + ;; When fields are mutable, a subtype's reference fields cannot be subtypes of + ;; the supertype's fields, they must match exactly. + (type $a (sub (struct (field (mut (ref null any)))))) + (type $b (sub $a (struct (field (mut (ref null none)))))) + ) + "sub type 1 does not match super type" +) + +(assert_invalid + (module + ;; When fields are const, a subtype's reference fields cannot be supertypes of + ;; the supertype's fields, they must be subtypes. + (type $a (sub (struct (field (ref null none))))) + (type $b (sub $a (struct (field (ref null any))))) + ) + "sub type 1 does not match super type" + ) + +(assert_invalid + (module + ;; The mutability of fields must be the same. + (type $c (sub (struct (field (mut (ref null any)))))) + (type $d (sub $c (struct (field (ref null any))))) + ) + "sub type 1 does not match super type" +) + +(assert_invalid + (module + ;; The mutability of fields must be the same. + (type $c (sub (struct (field (ref null any))))) + (type $d (sub $c (struct (field (mut (ref null any)))))) + ) + "sub type 1 does not match super type" +) From a50f1a08bf527e2422b217aeab18fe646dc7794f Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Mon, 9 Dec 2024 11:24:51 +0100 Subject: [PATCH 15/16] Correct element segment type expansion --- document/core/binary/modules.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/document/core/binary/modules.rst b/document/core/binary/modules.rst index ac405f4eef..8e97763326 100644 --- a/document/core/binary/modules.rst +++ b/document/core/binary/modules.rst @@ -356,7 +356,7 @@ It decodes into a vector of :ref:`element segments ` that represent \{ \ETYPE~\X{et}, \EINIT~((\REFFUNC~y)~\END)^\ast, \EMODE~\EDECLARATIVE \} \\ &&|& 4{:}\Bu32~~e{:}\Bexpr~~\X{el}^\ast{:}\Bvec(\Bexpr) &\Rightarrow& \\&&&\quad - \{ \ETYPE~(\REF~\FUNC), \EINIT~\X{el}^\ast, \EMODE~\EACTIVE~\{ \ETABLE~0, \EOFFSET~e \} \} \\ &&|& + \{ \ETYPE~(\REF~\NULL~\FUNC), \EINIT~\X{el}^\ast, \EMODE~\EACTIVE~\{ \ETABLE~0, \EOFFSET~e \} \} \\ &&|& 5{:}\Bu32~~\X{et}:\Breftype~~\X{el}^\ast{:}\Bvec(\Bexpr) &\Rightarrow& \\&&&\quad \{ \ETYPE~et, \EINIT~\X{el}^\ast, \EMODE~\EPASSIVE \} \\ &&|& From 74d2ec81d15efd3c0f2fba46a023f376101d8e46 Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Mon, 9 Dec 2024 11:36:27 +0100 Subject: [PATCH 16/16] Add active elemmode type refinement to changes --- document/core/appendix/changes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/document/core/appendix/changes.rst b/document/core/appendix/changes.rst index 012386e6d8..f66b7b8158 100644 --- a/document/core/appendix/changes.rst +++ b/document/core/appendix/changes.rst @@ -162,6 +162,8 @@ Added more precise types for references [#proposal-typedref]_. * Refined typing of :ref:`local instructions ` and :ref:`instruction sequences ` to track the :ref:`initialization status ` of :ref:`locals ` with non-:ref:`defaultable ` type +* Refined decoding of :ref:`active ` :ref:`element segments ` with implicit element type and plain function indices (opcode :math:`0`) to produce :ref:`non-nullable ` :ref:`reference type `. + * Extended :ref:`table definitions ` with optional initializer expression