Skip to content

Commit

Permalink
Drop support for type annotations on array.len (WebAssembly#6197)
Browse files Browse the repository at this point in the history
These type annotations were removed during the development of the GC proposal,
but we maintained support for parsing them to ease the transition. Now that GC
is shipped, remove support for the non-standard annotation and update our tests
accordingly.
  • Loading branch information
tlively authored and radekdoulik committed Jul 12, 2024
1 parent fb4cfc6 commit 19f80df
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
9 changes: 1 addition & 8 deletions src/wasm/wasm-s-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3160,14 +3160,7 @@ Expression* SExpressionWasmBuilder::makeArraySet(Element& s) {
}

Expression* SExpressionWasmBuilder::makeArrayLen(Element& s) {
// There may or may not be a type annotation.
Index i = 1;
try {
parseHeapType(*s[i]);
++i;
} catch (...) {
}
auto ref = parseExpression(*s[i]);
auto ref = parseExpression(*s[1]);
return Builder(wasm).makeArrayLen(ref);
}

Expand Down
7 changes: 3 additions & 4 deletions test/lit/arrays.wast
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
;; ROUNDTRIP-NEXT: )
;; ROUNDTRIP-NEXT: )
(func $len (param $a (ref array)) (result i32)
;; TODO: remove the unused type annotation
(array.len $byte-array
(array.len
(local.get $a)
)
)
Expand All @@ -77,7 +76,7 @@
;; ROUNDTRIP-NEXT: )
;; ROUNDTRIP-NEXT: )
(func $impossible-len (param $none nullref) (result i32)
(array.len $byte-array
(array.len
(local.get $none)
)
)
Expand All @@ -91,7 +90,7 @@
;; ROUNDTRIP-NEXT: (unreachable)
;; ROUNDTRIP-NEXT: )
(func $unreachable-len (param $a arrayref) (result i32)
(array.len $byte-array
(array.len
(unreachable)
)
)
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/gufa-refs.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4153,7 +4153,7 @@
;; CHECK-NEXT: )
(func $arrays (param $B (ref $B))
(drop
(array.len $B
(array.len
(array.new_fixed $B 2
(ref.null none)
(ref.null none)
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/gufa-tnh.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@
(i32.const 3)
)
(drop
(array.len $B
(array.len
(local.get $array.len)
)
)
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/optimize-instructions-gc.wast
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
)
)
(drop
(array.len $array
(array.len
(ref.as_non_null
(local.get $y)
)
Expand Down
4 changes: 2 additions & 2 deletions test/passes/Oz_fuzz-exec_all-features.wast
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
)
;; The length should be 50
(call $log
(array.len $bytes (local.get $x))
(array.len (local.get $x))
)
;; The value should be 42
(call $log
Expand Down Expand Up @@ -281,7 +281,7 @@
)
;; The length should be 2
(call $log
(array.len $bytes (local.get $x))
(array.len (local.get $x))
)
;; The first value should be 42
(call $log
Expand Down
2 changes: 1 addition & 1 deletion test/spec/array.wast
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
)

(func $len (param $v (ref $vec)) (result i32)
(array.len $vec (local.get $v))
(array.len (local.get $v))
)
(func (export "len") (result i32)
(call $len (array.new_default $vec (i32.const 3)))
Expand Down

0 comments on commit 19f80df

Please sign in to comment.