From 0afab1ee0b3422d1bdaa11c2e5c217280a034672 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 21 Dec 2023 00:43:35 -0800 Subject: [PATCH] Drop support for type annotations on array.len 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. --- src/wasm/wasm-s-parser.cpp | 9 +-------- test/lit/arrays.wast | 7 +++---- test/lit/passes/gufa-refs.wast | 2 +- test/lit/passes/gufa-tnh.wast | 2 +- test/lit/passes/optimize-instructions-gc.wast | 2 +- test/passes/Oz_fuzz-exec_all-features.wast | 4 ++-- test/spec/array.wast | 2 +- 7 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 42785e40eba..9f5f412be82 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -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); } diff --git a/test/lit/arrays.wast b/test/lit/arrays.wast index 47338fdf126..4dde528cf21 100644 --- a/test/lit/arrays.wast +++ b/test/lit/arrays.wast @@ -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) ) ) @@ -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) ) ) @@ -91,7 +90,7 @@ ;; ROUNDTRIP-NEXT: (unreachable) ;; ROUNDTRIP-NEXT: ) (func $unreachable-len (param $a arrayref) (result i32) - (array.len $byte-array + (array.len (unreachable) ) ) diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast index a99df47e06a..6aa741eb1b7 100644 --- a/test/lit/passes/gufa-refs.wast +++ b/test/lit/passes/gufa-refs.wast @@ -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) diff --git a/test/lit/passes/gufa-tnh.wast b/test/lit/passes/gufa-tnh.wast index 3a9c77a3098..b3d5b122b67 100644 --- a/test/lit/passes/gufa-tnh.wast +++ b/test/lit/passes/gufa-tnh.wast @@ -1803,7 +1803,7 @@ (i32.const 3) ) (drop - (array.len $B + (array.len (local.get $array.len) ) ) diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast index cbf44aee4d9..cb732d68b31 100644 --- a/test/lit/passes/optimize-instructions-gc.wast +++ b/test/lit/passes/optimize-instructions-gc.wast @@ -366,7 +366,7 @@ ) ) (drop - (array.len $array + (array.len (ref.as_non_null (local.get $y) ) diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast index 83cee56e866..1d2b106b7ee 100644 --- a/test/passes/Oz_fuzz-exec_all-features.wast +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -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 @@ -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 diff --git a/test/spec/array.wast b/test/spec/array.wast index 6e7b8cddb19..d9b75e28710 100644 --- a/test/spec/array.wast +++ b/test/spec/array.wast @@ -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)))