diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/binaryen.js/kitchen-sink.js | 8 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 27 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 100 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.txt | 91 | ||||
-rw-r--r-- | test/gtest/type-builder.cpp | 86 | ||||
-rw-r--r-- | test/lit/ctor-eval/string_view.wast | 32 | ||||
-rw-r--r-- | test/lit/exec/strings.wast | 31 | ||||
-rw-r--r-- | test/lit/passes/j2cl-inline.wast | 13 | ||||
-rw-r--r-- | test/lit/passes/precompute-strings.wast | 40 | ||||
-rw-r--r-- | test/lit/passes/roundtrip.wast | 66 | ||||
-rw-r--r-- | test/lit/passes/simplify-locals-strings.wast | 66 | ||||
-rw-r--r-- | test/lit/passes/string-lowering-instructions.wast | 134 | ||||
-rw-r--r-- | test/lit/string.as_wtf16.wast | 346 | ||||
-rw-r--r-- | test/lit/strings.wast | 222 | ||||
-rw-r--r-- | test/lit/wat-kitchen-sink.wast | 178 |
15 files changed, 455 insertions, 985 deletions
diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 52975f8bc..da281910f 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -179,13 +179,8 @@ function test_ids() { console.log("StringEncode: " + binaryen.StringEncodeId); console.log("StringConcat: " + binaryen.StringConcatId); console.log("StringEq: " + binaryen.StringEqId); - console.log("StringAs: " + binaryen.StringAsId); - console.log("StringWTF8Advance: " + binaryen.StringWTF8AdvanceId); console.log("StringWTF16Get: " + binaryen.StringWTF16GetId); - console.log("StringIterNext: " + binaryen.StringIterNextId); - console.log("StringIterMove: " + binaryen.StringIterMoveId); console.log("StringSliceWTF: " + binaryen.StringSliceWTFId); - console.log("StringSliceIter: " + binaryen.StringSliceIterId); } function test_core() { @@ -662,9 +657,6 @@ function test_core() { module.i31ref.pop(), module.structref.pop(), module.stringref.pop(), - module.stringview_wtf8.pop(), - module.stringview_wtf16.pop(), - module.stringview_iter.pop(), // Memory module.memory.size(), diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 2c54f1142..a3e88703e 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -109,13 +109,8 @@ StringMeasure: 81 StringEncode: 82 StringConcat: 83 StringEq: 84 -StringAs: 85 -StringWTF8Advance: 86 -StringWTF16Get: 87 -StringIterNext: 88 -StringIterMove: 89 -StringSliceWTF: 90 -StringSliceIter: 91 +StringWTF16Get: 85 +StringSliceWTF: 86 getExpressionInfo={"id":15,"type":4,"op":6} (f32.neg (f32.const -33.61199951171875) @@ -2191,15 +2186,6 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (pop stringref) ) (drop - (pop stringview_wtf8) - ) - (drop - (pop stringview_wtf16) - ) - (drop - (pop stringview_iter) - ) - (drop (memory.size) ) (drop @@ -4301,15 +4287,6 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (pop stringref) ) (drop - (pop stringview_wtf8) - ) - (drop - (pop stringview_wtf16) - ) - (drop - (pop stringview_iter) - ) - (drop (memory.size) ) (drop diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 66cf43290..1b78ea1e7 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -283,24 +283,6 @@ void test_types() { BinaryenTypeExpand(stringref, &valueType); assert(valueType == stringref); - BinaryenType stringview_wtf8_ = BinaryenTypeStringviewWTF8(); - printf("BinaryenTypeStringviewWTF8: (ptr)\n"); - assert(BinaryenTypeArity(stringview_wtf8_) == 1); - BinaryenTypeExpand(stringview_wtf8_, &valueType); - assert(valueType == stringview_wtf8_); - - BinaryenType stringview_wtf16_ = BinaryenTypeStringviewWTF16(); - printf("BinaryenTypeStringviewWTF16: (ptr)\n"); - assert(BinaryenTypeArity(stringview_wtf16_) == 1); - BinaryenTypeExpand(stringview_wtf16_, &valueType); - assert(valueType == stringview_wtf16_); - - BinaryenType stringview_iter_ = BinaryenTypeStringviewIter(); - printf("BinaryenTypeStringviewIter: (ptr)\n"); - assert(BinaryenTypeArity(stringview_iter_) == 1); - BinaryenTypeExpand(stringview_iter_, &valueType); - assert(valueType == stringview_iter_); - BinaryenType nullref = BinaryenTypeNullref(); printf("BinaryenTypeNullref: (ptr)\n"); assert(BinaryenTypeArity(nullref) == 1); @@ -351,12 +333,6 @@ void test_types() { printf("BinaryenHeapTypeStruct: %zd\n", BinaryenHeapTypeStruct()); printf("BinaryenHeapTypeArray: %zd\n", BinaryenHeapTypeArray()); printf("BinaryenHeapTypeString: %zd\n", BinaryenHeapTypeString()); - printf("BinaryenHeapTypeStringviewWTF8: %zd\n", - BinaryenHeapTypeStringviewWTF8()); - printf("BinaryenHeapTypeStringviewWTF16: %zd\n", - BinaryenHeapTypeStringviewWTF16()); - printf("BinaryenHeapTypeStringviewIter: %zd\n", - BinaryenHeapTypeStringviewIter()); printf("BinaryenHeapTypeNone: %zd\n", BinaryenHeapTypeNone()); printf("BinaryenHeapTypeNoext: %zd\n", BinaryenHeapTypeNoext()); printf("BinaryenHeapTypeNofunc: %zd\n", BinaryenHeapTypeNofunc()); @@ -1287,13 +1263,6 @@ void test_core() { module, BinaryenStringMeasureIsUSV(), BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), - BinaryenStringMeasure( - module, - BinaryenStringMeasureWTF16View(), - BinaryenStringAs( - module, - BinaryenStringAsWTF16(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()))), BinaryenStringEncode( module, BinaryenStringEncodeUTF8(), @@ -1356,80 +1325,15 @@ void test_core() { BinaryenStringEqCompare(), BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()), BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), - BinaryenStringAs( - module, - BinaryenStringAsWTF8(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), - BinaryenStringAs( - module, - BinaryenStringAsWTF16(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), - BinaryenStringAs( - module, - BinaryenStringAsIter(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), - BinaryenStringWTF8Advance( - module, - BinaryenStringAs( - module, - BinaryenStringAsWTF8(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), - makeInt32(module, 0), - makeInt32(module, 0)), BinaryenStringWTF16Get( module, - BinaryenStringAs( - module, - BinaryenStringAsWTF16(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), - makeInt32(module, 0)), - BinaryenStringIterNext( - module, - BinaryenStringAs( - module, - BinaryenStringAsIter(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()))), - BinaryenStringIterMove( - module, - BinaryenStringIterMoveAdvance(), - BinaryenStringAs( - module, - BinaryenStringAsIter(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), - makeInt32(module, 1)), - BinaryenStringIterMove( - module, - BinaryenStringIterMoveRewind(), - BinaryenStringAs( - module, - BinaryenStringAsIter(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), - makeInt32(module, 1)), - BinaryenStringSliceWTF( - module, - BinaryenStringSliceWTF8(), - BinaryenStringAs( - module, - BinaryenStringAsWTF8(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), - makeInt32(module, 0), + BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()), makeInt32(module, 0)), BinaryenStringSliceWTF( module, - BinaryenStringSliceWTF16(), - BinaryenStringAs( - module, - BinaryenStringAsWTF16(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), + BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()), makeInt32(module, 0), makeInt32(module, 0)), - BinaryenStringSliceIter( - module, - BinaryenStringAs( - module, - BinaryenStringAsIter(), - BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())), - makeInt32(module, 0)), // Other BinaryenNop(module), BinaryenUnreachable(module), diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index fe784a453..e10c3b47b 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -13,9 +13,6 @@ BinaryenTypeI31ref: (ptr) BinaryenTypeStructref: (ptr) BinaryenTypeArrayref: (ptr) BinaryenTypeStringref: (ptr) -BinaryenTypeStringviewWTF8: (ptr) -BinaryenTypeStringviewWTF16: (ptr) -BinaryenTypeStringviewIter: (ptr) BinaryenTypeNullref: (ptr) BinaryenTypeNullExternref: (ptr) BinaryenTypeNullFuncref: (ptr) @@ -31,12 +28,9 @@ BinaryenHeapTypeI31: 5 BinaryenHeapTypeStruct: 6 BinaryenHeapTypeArray: 7 BinaryenHeapTypeString: 9 -BinaryenHeapTypeStringviewWTF8: 10 -BinaryenHeapTypeStringviewWTF16: 11 -BinaryenHeapTypeStringviewIter: 12 -BinaryenHeapTypeNone: 13 -BinaryenHeapTypeNoext: 14 -BinaryenHeapTypeNofunc: 15 +BinaryenHeapTypeNone: 10 +BinaryenHeapTypeNoext: 11 +BinaryenHeapTypeNofunc: 12 BinaryenFeatureMVP: 0 BinaryenFeatureAtomics: 1 BinaryenFeatureBulkMemory: 16 @@ -2436,13 +2430,6 @@ BinaryenFeatureAll: 131071 ) ) (drop - (stringview_wtf16.length - (string.as_wtf16 - (global.get $string-global) - ) - ) - ) - (drop (string.encode_utf8 (global.get $string-global) (i32.const 0) @@ -2513,83 +2500,15 @@ BinaryenFeatureAll: 131071 ) ) (drop - (string.as_wtf8 - (global.get $string-global) - ) - ) - (drop - (string.as_wtf16 - (global.get $string-global) - ) - ) - (drop - (string.as_iter - (global.get $string-global) - ) - ) - (drop - (stringview_wtf8.advance - (string.as_wtf8 - (global.get $string-global) - ) - (i32.const 0) - (i32.const 0) - ) - ) - (drop (stringview_wtf16.get_codeunit - (string.as_wtf16 - (global.get $string-global) - ) - (i32.const 0) - ) - ) - (drop - (stringview_iter.next - (string.as_iter - (global.get $string-global) - ) - ) - ) - (drop - (stringview_iter.advance - (string.as_iter - (global.get $string-global) - ) - (i32.const 1) - ) - ) - (drop - (stringview_iter.rewind - (string.as_iter - (global.get $string-global) - ) - (i32.const 1) - ) - ) - (drop - (stringview_wtf8.slice - (string.as_wtf8 - (global.get $string-global) - ) - (i32.const 0) + (global.get $string-global) (i32.const 0) ) ) (drop (stringview_wtf16.slice - (string.as_wtf16 - (global.get $string-global) - ) - (i32.const 0) + (global.get $string-global) (i32.const 0) - ) - ) - (drop - (stringview_iter.slice - (string.as_iter - (global.get $string-global) - ) (i32.const 0) ) ) diff --git a/test/gtest/type-builder.cpp b/test/gtest/type-builder.cpp index 3c97028a4..443a7ee66 100644 --- a/test/gtest/type-builder.cpp +++ b/test/gtest/type-builder.cpp @@ -528,9 +528,6 @@ TEST_F(TypeTest, TestHeapTypeRelations) { HeapType struct_ = HeapType::struct_; HeapType array = HeapType::array; HeapType string = HeapType::string; - HeapType stringview_wtf8 = HeapType::stringview_wtf8; - HeapType stringview_wtf16 = HeapType::stringview_wtf16; - HeapType stringview_iter = HeapType::stringview_iter; HeapType none = HeapType::none; HeapType noext = HeapType::noext; HeapType nofunc = HeapType::nofunc; @@ -553,29 +550,23 @@ TEST_F(TypeTest, TestHeapTypeRelations) { } else if (lub && *lub == b) { EXPECT_TRUE(HeapType::isSubType(a, b)); EXPECT_FALSE(HeapType::isSubType(b, a)); - // This would hold except for the case of stringview types and none, where - // stringview types are their own top types, but we return `any` as the - // top type of none. - // EXPECT_EQ(a.getTop(), b.getTop()); + EXPECT_EQ(a.getTop(), b.getTop()); EXPECT_EQ(a.getBottom(), b.getBottom()); } else if (lub && *lub == a) { EXPECT_FALSE(HeapType::isSubType(a, b)); EXPECT_TRUE(HeapType::isSubType(b, a)); - // EXPECT_EQ(a.getTop(), b.getTop()); + EXPECT_EQ(a.getTop(), b.getTop()); EXPECT_EQ(a.getBottom(), b.getBottom()); } else if (lub) { EXPECT_FALSE(HeapType::isSubType(a, b)); EXPECT_FALSE(HeapType::isSubType(b, a)); - // EXPECT_EQ(a.getTop(), b.getTop()); + EXPECT_EQ(a.getTop(), b.getTop()); EXPECT_EQ(a.getBottom(), b.getBottom()); } else { EXPECT_FALSE(HeapType::isSubType(a, b)); EXPECT_FALSE(HeapType::isSubType(b, a)); EXPECT_NE(a.getTop(), b.getTop()); - // This would hold except for stringview types, which share a bottom with - // the anyref hierarchy despite having no shared upper bound with its - // types. - // EXPECT_NE(a.getBottom(), b.getBottom()); + EXPECT_NE(a.getBottom(), b.getBottom()); } }; @@ -588,9 +579,6 @@ TEST_F(TypeTest, TestHeapTypeRelations) { assertLUB(ext, struct_, {}); assertLUB(ext, array, {}); assertLUB(ext, string, {}); - assertLUB(ext, stringview_wtf8, {}); - assertLUB(ext, stringview_wtf16, {}); - assertLUB(ext, stringview_iter, {}); assertLUB(ext, none, {}); assertLUB(ext, noext, ext); assertLUB(ext, nofunc, {}); @@ -607,9 +595,6 @@ TEST_F(TypeTest, TestHeapTypeRelations) { assertLUB(func, struct_, {}); assertLUB(func, array, {}); assertLUB(func, string, {}); - assertLUB(func, stringview_wtf8, {}); - assertLUB(func, stringview_wtf16, {}); - assertLUB(func, stringview_iter, {}); assertLUB(func, none, {}); assertLUB(func, noext, {}); assertLUB(func, nofunc, func); @@ -627,9 +612,6 @@ TEST_F(TypeTest, TestHeapTypeRelations) { assertLUB(cont, struct_, {}); assertLUB(cont, array, {}); assertLUB(cont, string, {}); - assertLUB(cont, stringview_wtf8, {}); - assertLUB(cont, stringview_wtf16, {}); - assertLUB(cont, stringview_iter, {}); assertLUB(cont, none, {}); assertLUB(cont, noext, {}); assertLUB(cont, nofunc, {}); @@ -646,9 +628,6 @@ TEST_F(TypeTest, TestHeapTypeRelations) { assertLUB(any, struct_, any); assertLUB(any, array, any); assertLUB(any, string, any); - assertLUB(any, stringview_wtf8, {}); - assertLUB(any, stringview_wtf16, {}); - assertLUB(any, stringview_iter, {}); assertLUB(any, none, any); assertLUB(any, noext, {}); assertLUB(any, nofunc, {}); @@ -664,9 +643,6 @@ TEST_F(TypeTest, TestHeapTypeRelations) { assertLUB(eq, struct_, eq); assertLUB(eq, array, eq); assertLUB(eq, string, any); - assertLUB(eq, stringview_wtf8, {}); - assertLUB(eq, stringview_wtf16, {}); - assertLUB(eq, stringview_iter, {}); assertLUB(eq, none, eq); assertLUB(eq, noext, {}); assertLUB(eq, nofunc, {}); @@ -681,9 +657,6 @@ TEST_F(TypeTest, TestHeapTypeRelations) { assertLUB(i31, struct_, eq); assertLUB(i31, array, eq); assertLUB(i31, string, any); - assertLUB(i31, stringview_wtf8, {}); - assertLUB(i31, stringview_wtf16, {}); - assertLUB(i31, stringview_iter, {}); assertLUB(i31, none, i31); assertLUB(i31, noext, {}); assertLUB(i31, nofunc, {}); @@ -697,9 +670,6 @@ TEST_F(TypeTest, TestHeapTypeRelations) { assertLUB(struct_, cont, {}); assertLUB(struct_, array, eq); assertLUB(struct_, string, any); - assertLUB(struct_, stringview_wtf8, {}); - assertLUB(struct_, stringview_wtf16, {}); - assertLUB(struct_, stringview_iter, {}); assertLUB(struct_, none, struct_); assertLUB(struct_, noext, {}); assertLUB(struct_, nofunc, {}); @@ -712,9 +682,6 @@ TEST_F(TypeTest, TestHeapTypeRelations) { assertLUB(array, array, array); assertLUB(array, cont, {}); assertLUB(array, string, any); - assertLUB(array, stringview_wtf8, {}); - assertLUB(array, stringview_wtf16, {}); - assertLUB(array, stringview_iter, {}); assertLUB(array, none, array); assertLUB(array, noext, {}); assertLUB(array, nofunc, {}); @@ -726,9 +693,6 @@ TEST_F(TypeTest, TestHeapTypeRelations) { assertLUB(string, string, string); assertLUB(string, cont, {}); - assertLUB(string, stringview_wtf8, {}); - assertLUB(string, stringview_wtf16, {}); - assertLUB(string, stringview_iter, {}); assertLUB(string, none, string); assertLUB(string, noext, {}); assertLUB(string, nofunc, {}); @@ -738,39 +702,6 @@ TEST_F(TypeTest, TestHeapTypeRelations) { assertLUB(string, defStruct, any); assertLUB(string, defArray, any); - assertLUB(stringview_wtf8, stringview_wtf8, stringview_wtf8); - assertLUB(stringview_wtf8, stringview_wtf16, {}); - assertLUB(stringview_wtf8, stringview_iter, {}); - assertLUB(stringview_wtf8, none, stringview_wtf8); - assertLUB(stringview_wtf8, noext, {}); - assertLUB(stringview_wtf8, nofunc, {}); - assertLUB(stringview_wtf8, nocont, {}); - assertLUB(stringview_wtf8, defFunc, {}); - assertLUB(stringview_wtf8, defStruct, {}); - assertLUB(stringview_wtf8, defCont, {}); - assertLUB(stringview_wtf8, defArray, {}); - - assertLUB(stringview_wtf16, stringview_wtf16, stringview_wtf16); - assertLUB(stringview_wtf16, stringview_iter, {}); - assertLUB(stringview_wtf16, none, stringview_wtf16); - assertLUB(stringview_wtf16, noext, {}); - assertLUB(stringview_wtf16, nofunc, {}); - assertLUB(stringview_wtf16, nocont, {}); - assertLUB(stringview_wtf16, defFunc, {}); - assertLUB(stringview_wtf16, defStruct, {}); - assertLUB(stringview_wtf16, defCont, {}); - assertLUB(stringview_wtf16, defArray, {}); - - assertLUB(stringview_iter, stringview_iter, stringview_iter); - assertLUB(stringview_iter, none, stringview_iter); - assertLUB(stringview_iter, noext, {}); - assertLUB(stringview_iter, nofunc, {}); - assertLUB(stringview_iter, nocont, {}); - assertLUB(stringview_iter, defFunc, {}); - assertLUB(stringview_iter, defStruct, {}); - assertLUB(stringview_iter, defCont, {}); - assertLUB(stringview_iter, defArray, {}); - assertLUB(none, none, none); assertLUB(none, noext, {}); assertLUB(none, nofunc, {}); @@ -1113,9 +1044,6 @@ TEST_F(TypeTest, TestDepth) { EXPECT_EQ(HeapType(HeapType::i31).getDepth(), 2U); EXPECT_EQ(HeapType(HeapType::string).getDepth(), 2U); - EXPECT_EQ(HeapType(HeapType::stringview_wtf8).getDepth(), 2U); - EXPECT_EQ(HeapType(HeapType::stringview_wtf16).getDepth(), 2U); - EXPECT_EQ(HeapType(HeapType::stringview_iter).getDepth(), 2U); EXPECT_EQ(HeapType(HeapType::none).getDepth(), size_t(-1)); EXPECT_EQ(HeapType(HeapType::nofunc).getDepth(), size_t(-1)); @@ -1182,9 +1110,6 @@ TEST_F(TypeTest, TestSupertypes) { ASSERT_FALSE(HeapType(HeapType::struct_).getDeclaredSuperType()); ASSERT_FALSE(HeapType(HeapType::array).getDeclaredSuperType()); ASSERT_FALSE(HeapType(HeapType::string).getDeclaredSuperType()); - ASSERT_FALSE(HeapType(HeapType::stringview_wtf8).getDeclaredSuperType()); - ASSERT_FALSE(HeapType(HeapType::stringview_wtf16).getDeclaredSuperType()); - ASSERT_FALSE(HeapType(HeapType::stringview_iter).getDeclaredSuperType()); ASSERT_FALSE(HeapType(HeapType::none).getDeclaredSuperType()); ASSERT_FALSE(HeapType(HeapType::noext).getDeclaredSuperType()); ASSERT_FALSE(HeapType(HeapType::nofunc).getDeclaredSuperType()); @@ -1200,9 +1125,6 @@ TEST_F(TypeTest, TestSupertypes) { ASSERT_EQ(HeapType(HeapType::struct_).getSuperType(), HeapType::eq); ASSERT_EQ(HeapType(HeapType::array).getSuperType(), HeapType::eq); ASSERT_FALSE(HeapType(HeapType::string).getSuperType()); - ASSERT_FALSE(HeapType(HeapType::stringview_wtf8).getSuperType()); - ASSERT_FALSE(HeapType(HeapType::stringview_wtf16).getSuperType()); - ASSERT_FALSE(HeapType(HeapType::stringview_iter).getSuperType()); ASSERT_FALSE(HeapType(HeapType::none).getSuperType()); ASSERT_FALSE(HeapType(HeapType::noext).getSuperType()); ASSERT_FALSE(HeapType(HeapType::nofunc).getSuperType()); diff --git a/test/lit/ctor-eval/string_view.wast b/test/lit/ctor-eval/string_view.wast deleted file mode 100644 index 5906e4f60..000000000 --- a/test/lit/ctor-eval/string_view.wast +++ /dev/null @@ -1,32 +0,0 @@ -;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. -;; RUN: foreach %s %t wasm-ctor-eval --ctors=test --kept-exports=test --quiet -all -S -o - | filecheck %s - -;; We cannot precompute string views atm. - -(module - ;; CHECK: (type $0 (func)) - - ;; CHECK: (export "test" (func $test)) - (export "test" (func $test)) - - ;; CHECK: (func $test (type $0) - ;; CHECK-NEXT: (local $temp-view (ref stringview_wtf16)) - ;; CHECK-NEXT: (local.set $temp-view - ;; CHECK-NEXT: (string.as_wtf16 - ;; CHECK-NEXT: (string.const "test") - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $test - (local $temp-view (ref stringview_wtf16)) - ;; This code will remain: we cannot precompute a value that we store in a - ;; global, as string.as is not a constant instruction that can appear in a - ;; global. - (local.set $temp-view - (string.as_wtf16 - (string.const "test") - ) - ) - ) -) - diff --git a/test/lit/exec/strings.wast b/test/lit/exec/strings.wast index 0d5bb7dc4..ca77f9882 100644 --- a/test/lit/exec/strings.wast +++ b/test/lit/exec/strings.wast @@ -171,24 +171,11 @@ (func $get_codeunit (export "get_codeunit") (result i32) ;; Reads 'c' which is code 99. (stringview_wtf16.get_codeunit - (string.as_wtf16 - (string.const "abcdefg") - ) + (string.const "abcdefg") (i32.const 2) ) ) - ;; CHECK: [fuzz-exec] calling get_length - ;; CHECK-NEXT: [fuzz-exec] note result: get_length => 7 - (func $get_length (export "get_length") (result i32) - ;; This should return 7. - (stringview_wtf16.length - (string.as_wtf16 - (string.const "1234567") - ) - ) - ) - ;; CHECK: [fuzz-exec] calling encode ;; CHECK-NEXT: [LoggingExternalInterface logging 3] ;; CHECK-NEXT: [LoggingExternalInterface logging 0] @@ -280,9 +267,7 @@ (func $slice (export "slice") (result (ref string)) ;; Slicing [3:6] here should definitely output "def". (stringview_wtf16.slice - (string.as_wtf16 - (string.const "abcdefgh") - ) + (string.const "abcdefgh") (i32.const 3) (i32.const 6) ) @@ -293,9 +278,7 @@ (func $slice-big (export "slice-big") (result (ref string)) ;; Slicing [3:huge unsigned value] leads to slicing til the end: "defgh". (stringview_wtf16.slice - (string.as_wtf16 - (string.const "abcdefgh") - ) + (string.const "abcdefgh") (i32.const 3) (i32.const -1) ) @@ -400,9 +383,7 @@ (func $slice-unicode (export "slice-unicode") (result (ref string)) (stringview_wtf16.slice ;; abcd£fgh - (string.as_wtf16 - (string.const "abcd\C2\A3fgh") - ) + (string.const "abcd\C2\A3fgh") (i32.const 3) (i32.const 6) ) @@ -535,9 +516,6 @@ ;; CHECK: [fuzz-exec] calling get_codeunit ;; CHECK-NEXT: [fuzz-exec] note result: get_codeunit => 99 -;; CHECK: [fuzz-exec] calling get_length -;; CHECK-NEXT: [fuzz-exec] note result: get_length => 7 - ;; CHECK: [fuzz-exec] calling encode ;; CHECK-NEXT: [LoggingExternalInterface logging 3] ;; CHECK-NEXT: [LoggingExternalInterface logging 0] @@ -629,7 +607,6 @@ ;; CHECK-NEXT: [fuzz-exec] comparing eq.4 ;; CHECK-NEXT: [fuzz-exec] comparing eq.5 ;; CHECK-NEXT: [fuzz-exec] comparing get_codeunit -;; CHECK-NEXT: [fuzz-exec] comparing get_length ;; CHECK-NEXT: [fuzz-exec] comparing invalid_code_point ;; CHECK-NEXT: [fuzz-exec] comparing isolated_high_code_point ;; CHECK-NEXT: [fuzz-exec] comparing isolated_low_code_point diff --git a/test/lit/passes/j2cl-inline.wast b/test/lit/passes/j2cl-inline.wast index 9148b5378..88485f999 100644 --- a/test/lit/passes/j2cl-inline.wast +++ b/test/lit/passes/j2cl-inline.wast @@ -6,16 +6,23 @@ (module ;; A once function that has become empty + ;; CHECK: (type $0 (func)) + + ;; CHECK: (global $$class-initialized@Zoo (mut i32) (i32.const 0)) + + ;; CHECK: (func $clinit-trivial-1_<once>_@Foo (type $0) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) (func $clinit-trivial-1_<once>_@Foo ) ;; A once function that just calls another + ;; CHECK: (func $clinit-trivial-2_<once>_@Bar (type $0) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) (func $clinit-trivial-2_<once>_@Bar (call $clinit-trivial-1_<once>_@Foo) ) - ;; CHECK: (type $0 (func)) - - ;; CHECK: (global $$class-initialized@Zoo (mut i32) (i32.const 0)) (global $$class-initialized@Zoo (mut i32) (i32.const 0)) ;; Not hoisted but trivial. diff --git a/test/lit/passes/precompute-strings.wast b/test/lit/passes/precompute-strings.wast index a9d065fdc..9d4ec3a7a 100644 --- a/test/lit/passes/precompute-strings.wast +++ b/test/lit/passes/precompute-strings.wast @@ -71,10 +71,8 @@ ;; CHECK-NEXT: (i32.const 7) ;; CHECK-NEXT: ) (func $length (result i32) - (stringview_wtf16.length - (string.as_wtf16 - (string.const "1234567") - ) + (string.measure_wtf16 + (string.const "1234567") ) ) @@ -82,11 +80,9 @@ ;; CHECK-NEXT: (i32.const 8) ;; CHECK-NEXT: ) (func $length-unicode (result i32) - (stringview_wtf16.length - (string.as_wtf16 - ;; $_£_€_𐍈 (the last character is encoded as a surrogate pair) - (string.const "$_\C2\A3_\E2\82\AC_\F0\90\8D\88") - ) + (string.measure_wtf16 + ;; $_£_€_𐍈 (the last character is encoded as a surrogate pair) + (string.const "$_\C2\A3_\E2\82\AC_\F0\90\8D\88") ) ) @@ -96,10 +92,8 @@ (func $get_codepoint (result i32) ;; Returns 95 ('_'). (stringview_wtf16.get_codeunit - (string.as_wtf16 - ;; $_£_€_𐍈 - (string.const "$_\C2\A3_\E2\82\AC_\F0\90\8D\88") - ) + ;; $_£_€_𐍈 + (string.const "$_\C2\A3_\E2\82\AC_\F0\90\8D\88") (i32.const 1) ) ) @@ -110,10 +104,8 @@ (func $get_codepoint-unicode (export "get_codepoint-unicode") (result i32) ;; Returns 8364 ('€') (stringview_wtf16.get_codeunit - (string.as_wtf16 - ;; $_£_€_𐍈 - (string.const "$_\C2\A3_\E2\82\AC_\F0\90\8D\88") - ) + ;; $_£_€_𐍈 + (string.const "$_\C2\A3_\E2\82\AC_\F0\90\8D\88") (i32.const 4) ) ) @@ -124,10 +116,8 @@ (func $get_codepoint-surrogate (export "get_codepoint-surrogate") (result i32) ;; Returns 0xd800 (the high surrogate in '𐍈') (stringview_wtf16.get_codeunit - (string.as_wtf16 - ;; $_£_€_𐍈 - (string.const "$_\C2\A3_\E2\82\AC_\F0\90\8D\88") - ) + ;; $_£_€_𐍈 + (string.const "$_\C2\A3_\E2\82\AC_\F0\90\8D\88") (i32.const 6) ) ) @@ -217,9 +207,7 @@ (func $slice (export "slice") (result (ref string)) ;; Slicing [3:6] here should definitely output "def". (stringview_wtf16.slice - (string.as_wtf16 - (string.const "abcdefgh") - ) + (string.const "abcdefgh") (i32.const 3) (i32.const 6) ) @@ -231,9 +219,7 @@ (func $slice-unicode (export "slice-unicode") (result (ref string)) (stringview_wtf16.slice ;; abcd£fgh - (string.as_wtf16 - (string.const "abcd\C2\A3fgh") - ) + (string.const "abcd\C2\A3fgh") (i32.const 3) (i32.const 6) ) diff --git a/test/lit/passes/roundtrip.wast b/test/lit/passes/roundtrip.wast index 8fb69cb7d..59e303eaf 100644 --- a/test/lit/passes/roundtrip.wast +++ b/test/lit/passes/roundtrip.wast @@ -42,70 +42,4 @@ ) ) ) - - ;; CHECK: (func $string_view_casts (type $2) (param $x stringview_wtf8) (param $y stringview_wtf16) (param $z stringview_iter) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (local.get $x) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (local.get $y) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (local.get $z) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (local.get $x) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (local.get $y) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (local.get $z) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string_view_casts - ;; ref.cast of string views is not allowed in binaries: replace with - ;; ref.as_non_null, or remove if it is a no-op. - (param $x (ref null stringview_wtf8)) - (param $y (ref null stringview_wtf16)) - (param $z (ref null stringview_iter)) - ;; Here we still need a cast to non-null. - (drop - (ref.cast (ref stringview_wtf8) - (local.get $x) - ) - ) - (drop - (ref.cast (ref stringview_wtf16) - (local.get $y) - ) - ) - (drop - (ref.cast (ref stringview_iter) - (local.get $z) - ) - ) - ;; Here we do not need the cast. - (drop - (ref.cast (ref null stringview_wtf8) - (local.get $x) - ) - ) - (drop - (ref.cast (ref null stringview_wtf16) - (local.get $y) - ) - ) - (drop - (ref.cast (ref null stringview_iter) - (local.get $z) - ) - ) - ) ) diff --git a/test/lit/passes/simplify-locals-strings.wast b/test/lit/passes/simplify-locals-strings.wast index 890364a83..d03875652 100644 --- a/test/lit/passes/simplify-locals-strings.wast +++ b/test/lit/passes/simplify-locals-strings.wast @@ -540,70 +540,4 @@ (local.get $temp) ) ) - - ;; CHECK: (func $no-iteration-past-each-other (type $6) (param $iter stringview_iter) - ;; CHECK-NEXT: (local $i32 i32) - ;; CHECK-NEXT: (local.set $i32 - ;; CHECK-NEXT: (stringview_iter.next - ;; CHECK-NEXT: (local.get $iter) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (stringview_iter.advance - ;; CHECK-NEXT: (local.get $iter) - ;; CHECK-NEXT: (i32.const 3) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (local.get $i32) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $i32 - ;; CHECK-NEXT: (stringview_iter.next - ;; CHECK-NEXT: (local.get $iter) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (stringview_iter.rewind - ;; CHECK-NEXT: (local.get $iter) - ;; CHECK-NEXT: (i32.const 4) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (local.get $i32) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $no-iteration-past-each-other - (param $iter stringview_iter) - (local $i32 i32) - ;; Iteration operations interact with each other, and can't be moved past - ;; each other. - (local.set $i32 - (stringview_iter.next - (local.get $iter) - ) - ) - (drop - (stringview_iter.advance - (local.get $iter) - (i32.const 3) - ) - ) - (drop - (local.get $i32) - ) - (local.set $i32 - (stringview_iter.next - (local.get $iter) - ) - ) - (drop - (stringview_iter.rewind - (local.get $iter) - (i32.const 4) - ) - ) - (drop - (local.get $i32) - ) - ) ) diff --git a/test/lit/passes/string-lowering-instructions.wast b/test/lit/passes/string-lowering-instructions.wast index 548586c4b..44c004ea5 100644 --- a/test/lit/passes/string-lowering-instructions.wast +++ b/test/lit/passes/string-lowering-instructions.wast @@ -42,33 +42,29 @@ ;; CHECK: (type $13 (func (param externref) (result externref))) - ;; CHECK: (type $14 (func (param externref) (result externref))) + ;; CHECK: (type $14 (func (param externref) (result i32))) - ;; CHECK: (type $15 (func (param externref) (result i32))) + ;; CHECK: (type $15 (func (param externref externref) (result i32))) - ;; CHECK: (type $16 (func (param externref externref) (result i32))) + ;; CHECK: (type $16 (func (param externref (ref $0)) (result i32))) - ;; CHECK: (type $17 (func (param externref (ref $0)) (result i32))) + ;; CHECK: (type $17 (func (param externref externref) (result (ref extern)))) - ;; CHECK: (type $18 (func (param externref externref) (result (ref extern)))) + ;; CHECK: (type $18 (func (param (ref $0)))) - ;; CHECK: (type $19 (func (param (ref $0)))) + ;; CHECK: (type $19 (func (param (ref null $0) i32 i32) (result (ref extern)))) - ;; CHECK: (type $20 (func (param externref (ref extern) externref externref externref (ref extern)))) + ;; CHECK: (type $20 (func (param i32) (result (ref extern)))) - ;; CHECK: (type $21 (func (param (ref null $0) i32 i32) (result (ref extern)))) + ;; CHECK: (type $21 (func (param externref externref) (result (ref extern)))) - ;; CHECK: (type $22 (func (param i32) (result (ref extern)))) + ;; CHECK: (type $22 (func (param externref (ref null $0) i32) (result i32))) - ;; CHECK: (type $23 (func (param externref externref) (result (ref extern)))) + ;; CHECK: (type $23 (func (param externref) (result i32))) - ;; CHECK: (type $24 (func (param externref (ref null $0) i32) (result i32))) + ;; CHECK: (type $24 (func (param externref i32) (result i32))) - ;; CHECK: (type $25 (func (param externref) (result i32))) - - ;; CHECK: (type $26 (func (param externref i32) (result i32))) - - ;; CHECK: (type $27 (func (param externref i32 i32) (result (ref extern)))) + ;; CHECK: (type $25 (func (param externref i32 i32) (result (ref extern)))) ;; CHECK: (import "string.const" "0" (global $string.const_exported (ref extern))) @@ -78,23 +74,23 @@ (import "colliding" "name" (func $fromCodePoint)) - ;; CHECK: (import "wasm:js-string" "fromCharCodeArray" (func $fromCharCodeArray (type $21) (param (ref null $0) i32 i32) (result (ref extern)))) + ;; CHECK: (import "wasm:js-string" "fromCharCodeArray" (func $fromCharCodeArray (type $19) (param (ref null $0) i32 i32) (result (ref extern)))) - ;; CHECK: (import "wasm:js-string" "fromCodePoint" (func $fromCodePoint_19 (type $22) (param i32) (result (ref extern)))) + ;; CHECK: (import "wasm:js-string" "fromCodePoint" (func $fromCodePoint_18 (type $20) (param i32) (result (ref extern)))) - ;; CHECK: (import "wasm:js-string" "concat" (func $concat (type $23) (param externref externref) (result (ref extern)))) + ;; CHECK: (import "wasm:js-string" "concat" (func $concat (type $21) (param externref externref) (result (ref extern)))) - ;; CHECK: (import "wasm:js-string" "intoCharCodeArray" (func $intoCharCodeArray (type $24) (param externref (ref null $0) i32) (result i32))) + ;; CHECK: (import "wasm:js-string" "intoCharCodeArray" (func $intoCharCodeArray (type $22) (param externref (ref null $0) i32) (result i32))) ;; CHECK: (import "wasm:js-string" "equals" (func $equals (type $2) (param externref externref) (result i32))) ;; CHECK: (import "wasm:js-string" "compare" (func $compare (type $2) (param externref externref) (result i32))) - ;; CHECK: (import "wasm:js-string" "length" (func $length (type $25) (param externref) (result i32))) + ;; CHECK: (import "wasm:js-string" "length" (func $length (type $23) (param externref) (result i32))) - ;; CHECK: (import "wasm:js-string" "charCodeAt" (func $charCodeAt (type $26) (param externref i32) (result i32))) + ;; CHECK: (import "wasm:js-string" "charCodeAt" (func $charCodeAt (type $24) (param externref i32) (result i32))) - ;; CHECK: (import "wasm:js-string" "substring" (func $substring (type $27) (param externref i32 i32) (result (ref extern)))) + ;; CHECK: (import "wasm:js-string" "substring" (func $substring (type $25) (param externref i32 i32) (result (ref extern)))) ;; CHECK: (global $string externref (ref.null noextern)) (global $string stringref (ref.null string)) ;; Test we update global nulls. @@ -103,73 +99,7 @@ ;; CHECK: (export "export.2" (func $exported-string-receiver)) - ;; CHECK: (func $string.as (type $20) (param $a externref) (param $a_nn (ref extern)) (param $b externref) (param $c externref) (param $d externref) (param $nn_view (ref extern)) - ;; CHECK-NEXT: (local.set $b - ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (local.get $a) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $c - ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (local.get $a) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $d - ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (local.get $a) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $nn_view - ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (local.get $a) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $nn_view - ;; CHECK-NEXT: (local.get $a_nn) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string.as - (param $a stringref) - (param $a_nn (ref string)) - (param $b stringview_wtf8) - (param $c stringview_wtf16) - (param $d stringview_iter) - (param $nn_view (ref stringview_wtf16)) - ;; These operations all vanish in the lowering, as they all become extref - ;; (JS strings). - (local.set $b - (string.as_wtf8 - (local.get $a) - ) - ) - (local.set $c - (string.as_wtf16 - (local.get $a) - ) - ) - (local.set $d - (string.as_iter - (local.get $a) - ) - ) - ;; The input is nullable, and string.as casts to non-null, so we will need - ;; to keep a cast here in order to validate. (We also add a cast in all the - ;; above as the inputs are nullable, but this is the only one that will - ;; fail to validate. Other opts can remove the above ones.) - (local.set $nn_view - (string.as_wtf16 - (local.get $a) - ) - ) - ;; The input is already non-nullable here, so no cast is needed. - (local.set $nn_view - (string.as_wtf16 - (local.get $a_nn) - ) - ) - ) - - ;; CHECK: (func $string.new.gc (type $19) (param $array16 (ref $0)) + ;; CHECK: (func $string.new.gc (type $18) (param $array16 (ref $0)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $fromCharCodeArray ;; CHECK-NEXT: (local.get $array16) @@ -189,7 +119,7 @@ ) ;; CHECK: (func $string.from_code_point (type $4) (result externref) - ;; CHECK-NEXT: (call $fromCodePoint_19 + ;; CHECK-NEXT: (call $fromCodePoint_18 ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -199,7 +129,7 @@ ) ) - ;; CHECK: (func $string.concat (type $18) (param $0 externref) (param $1 externref) (result (ref extern)) + ;; CHECK: (func $string.concat (type $17) (param $0 externref) (param $1 externref) (result (ref extern)) ;; CHECK-NEXT: (call $concat ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -212,7 +142,7 @@ ) ) - ;; CHECK: (func $string.encode (type $17) (param $ref externref) (param $array16 (ref $0)) (result i32) + ;; CHECK: (func $string.encode (type $16) (param $ref externref) (param $array16 (ref $0)) (result i32) ;; CHECK-NEXT: (call $intoCharCodeArray ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (local.get $array16) @@ -227,7 +157,7 @@ ) ) - ;; CHECK: (func $string.eq (type $16) (param $a externref) (param $b externref) (result i32) + ;; CHECK: (func $string.eq (type $15) (param $a externref) (param $b externref) (result i32) ;; CHECK-NEXT: (call $equals ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: (local.get $b) @@ -240,7 +170,7 @@ ) ) - ;; CHECK: (func $string.compare (type $16) (param $a externref) (param $b externref) (result i32) + ;; CHECK: (func $string.compare (type $15) (param $a externref) (param $b externref) (result i32) ;; CHECK-NEXT: (call $compare ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: (local.get $b) @@ -253,38 +183,38 @@ ) ) - ;; CHECK: (func $string.length (type $15) (param $ref externref) (result i32) + ;; CHECK: (func $string.length (type $14) (param $ref externref) (result i32) ;; CHECK-NEXT: (call $length ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $string.length (param $ref stringview_wtf16) (result i32) - (stringview_wtf16.length + (func $string.length (param $ref stringref) (result i32) + (string.measure_wtf16 (local.get $ref) ) ) - ;; CHECK: (func $string.get_codeunit (type $15) (param $ref externref) (result i32) + ;; CHECK: (func $string.get_codeunit (type $14) (param $ref externref) (result i32) ;; CHECK-NEXT: (call $charCodeAt ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $string.get_codeunit (param $ref stringview_wtf16) (result i32) + (func $string.get_codeunit (param $ref stringref) (result i32) (stringview_wtf16.get_codeunit (local.get $ref) (i32.const 2) ) ) - ;; CHECK: (func $string.slice (type $14) (param $ref externref) (result externref) + ;; CHECK: (func $string.slice (type $13) (param $ref externref) (result externref) ;; CHECK-NEXT: (call $substring ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: (i32.const 3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $string.slice (param $ref stringview_wtf16) (result stringref) + (func $string.slice (param $ref stringref) (result stringref) (stringview_wtf16.slice (local.get $ref) (i32.const 2) diff --git a/test/lit/string.as_wtf16.wast b/test/lit/string.as_wtf16.wast new file mode 100644 index 000000000..97a5d9055 --- /dev/null +++ b/test/lit/string.as_wtf16.wast @@ -0,0 +1,346 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. + +;; Check that string.as_wtf16 is accepted by the parser but is not translated +;; into any IR. + +;; RUN: wasm-opt %s -all -S -o - | filecheck %s +;; RUN: wasm-opt %s -all --shrink-level=3 --roundtrip -S -o - | filecheck %s --check-prefix=RTRIP +;; RUN: wasm-opt %s -all --shrink-level=3 --roundtrip --roundtrip -S -o - | filecheck %s --check-prefix=RRTRP + +(module + ;; CHECK: (func $empty (type $2) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; RTRIP: (func $empty (type $2) + ;; RTRIP-NEXT: ) + ;; RRTRP: (func $empty (type $2) + ;; RRTRP-NEXT: ) + (func $empty + (string.as_wtf16) + ) + + ;; CHECK: (func $codeunit (type $1) (result i32) + ;; CHECK-NEXT: (stringview_wtf16.get_codeunit + ;; CHECK-NEXT: (string.const "abc") + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; RTRIP: (func $codeunit (type $1) (result i32) + ;; RTRIP-NEXT: (local $0 i32) + ;; RTRIP-NEXT: (local $1 (ref string)) + ;; RTRIP-NEXT: (stringview_wtf16.get_codeunit + ;; RTRIP-NEXT: (block (result (ref string)) + ;; RTRIP-NEXT: (local.set $1 + ;; RTRIP-NEXT: (string.const "abc") + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.set $0 + ;; RTRIP-NEXT: (i32.const 0) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.get $1) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.get $0) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RRTRP: (func $codeunit (type $1) (result i32) + ;; RRTRP-NEXT: (local $0 i32) + ;; RRTRP-NEXT: (local $1 (ref string)) + ;; RRTRP-NEXT: (local $2 (ref string)) + ;; RRTRP-NEXT: (stringview_wtf16.get_codeunit + ;; RRTRP-NEXT: (block (result (ref string)) + ;; RRTRP-NEXT: (local.set $2 + ;; RRTRP-NEXT: (string.const "abc") + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.set $0 + ;; RRTRP-NEXT: (i32.const 0) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.get $2) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.get $0) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: ) + (func $codeunit (result i32) + ;; This should parse ok with the conversion skipped. The roundtrip will + ;; include scratch locals. + (stringview_wtf16.get_codeunit + (string.as_wtf16 + (string.const "abc") + ) + (i32.const 0) + ) + ) + + ;; CHECK: (func $codeunit-get (type $1) (result i32) + ;; CHECK-NEXT: (local $pos i32) + ;; CHECK-NEXT: (stringview_wtf16.get_codeunit + ;; CHECK-NEXT: (string.const "abc") + ;; CHECK-NEXT: (local.get $pos) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; RTRIP: (func $codeunit-get (type $1) (result i32) + ;; RTRIP-NEXT: (local $pos i32) + ;; RTRIP-NEXT: (stringview_wtf16.get_codeunit + ;; RTRIP-NEXT: (string.const "abc") + ;; RTRIP-NEXT: (local.get $pos) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RRTRP: (func $codeunit-get (type $1) (result i32) + ;; RRTRP-NEXT: (local $pos i32) + ;; RRTRP-NEXT: (stringview_wtf16.get_codeunit + ;; RRTRP-NEXT: (string.const "abc") + ;; RRTRP-NEXT: (local.get $pos) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: ) + (func $codeunit-get (result i32) + (local $pos i32) + ;; This will not use a scratch local for pos. + (stringview_wtf16.get_codeunit + (string.const "abc") + (local.get $pos) + ) + ) + + ;; CHECK: (func $slice (type $0) (result stringref) + ;; CHECK-NEXT: (stringview_wtf16.slice + ;; CHECK-NEXT: (string.const "abc") + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; RTRIP: (func $slice (type $0) (result stringref) + ;; RTRIP-NEXT: (local $0 i32) + ;; RTRIP-NEXT: (local $1 i32) + ;; RTRIP-NEXT: (local $2 i32) + ;; RTRIP-NEXT: (local $3 (ref string)) + ;; RTRIP-NEXT: (stringview_wtf16.slice + ;; RTRIP-NEXT: (block (result (ref string)) + ;; RTRIP-NEXT: (local.set $3 + ;; RTRIP-NEXT: (string.const "abc") + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.set $0 + ;; RTRIP-NEXT: (block (result i32) + ;; RTRIP-NEXT: (local.set $2 + ;; RTRIP-NEXT: (i32.const 1) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.set $1 + ;; RTRIP-NEXT: (i32.const 2) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.get $2) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.get $3) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.get $0) + ;; RTRIP-NEXT: (local.get $1) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RRTRP: (func $slice (type $0) (result stringref) + ;; RRTRP-NEXT: (local $0 i32) + ;; RRTRP-NEXT: (local $1 i32) + ;; RRTRP-NEXT: (local $2 i32) + ;; RRTRP-NEXT: (local $3 (ref string)) + ;; RRTRP-NEXT: (local $4 i32) + ;; RRTRP-NEXT: (local $5 (ref string)) + ;; RRTRP-NEXT: (stringview_wtf16.slice + ;; RRTRP-NEXT: (block (result (ref string)) + ;; RRTRP-NEXT: (local.set $5 + ;; RRTRP-NEXT: (string.const "abc") + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.set $0 + ;; RRTRP-NEXT: (block (result i32) + ;; RRTRP-NEXT: (local.set $4 + ;; RRTRP-NEXT: (i32.const 1) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.set $1 + ;; RRTRP-NEXT: (i32.const 2) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.get $4) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.get $5) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.get $0) + ;; RRTRP-NEXT: (local.get $1) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: ) + (func $slice (result stringref) + ;; This should parse ok with the conversion skipped. The roundtrip will + ;; include scratch locals. + (stringview_wtf16.slice + (string.as_wtf16 + (string.const "abc") + ) + (i32.const 1) + (i32.const 2) + ) + ) + + ;; CHECK: (func $slice-start-get (type $0) (result stringref) + ;; CHECK-NEXT: (local $start i32) + ;; CHECK-NEXT: (stringview_wtf16.slice + ;; CHECK-NEXT: (string.const "abc") + ;; CHECK-NEXT: (local.get $start) + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; RTRIP: (func $slice-start-get (type $0) (result stringref) + ;; RTRIP-NEXT: (local $start i32) + ;; RTRIP-NEXT: (local $1 i32) + ;; RTRIP-NEXT: (local $2 (ref string)) + ;; RTRIP-NEXT: (stringview_wtf16.slice + ;; RTRIP-NEXT: (block (result (ref string)) + ;; RTRIP-NEXT: (local.set $2 + ;; RTRIP-NEXT: (string.const "abc") + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.set $1 + ;; RTRIP-NEXT: (i32.const 2) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.get $2) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.get $start) + ;; RTRIP-NEXT: (local.get $1) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RRTRP: (func $slice-start-get (type $0) (result stringref) + ;; RRTRP-NEXT: (local $start i32) + ;; RRTRP-NEXT: (local $1 i32) + ;; RRTRP-NEXT: (local $2 (ref string)) + ;; RRTRP-NEXT: (local $3 (ref string)) + ;; RRTRP-NEXT: (stringview_wtf16.slice + ;; RRTRP-NEXT: (block (result (ref string)) + ;; RRTRP-NEXT: (local.set $3 + ;; RRTRP-NEXT: (string.const "abc") + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.set $1 + ;; RRTRP-NEXT: (i32.const 2) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.get $3) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.get $start) + ;; RRTRP-NEXT: (local.get $1) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: ) + (func $slice-start-get (result stringref) + (local $start i32) + (stringview_wtf16.slice + (string.const "abc") + (local.get $start) + (i32.const 2) + ) + ) + + + ;; CHECK: (func $slice-end-get (type $0) (result stringref) + ;; CHECK-NEXT: (local $end i32) + ;; CHECK-NEXT: (stringview_wtf16.slice + ;; CHECK-NEXT: (string.const "abc") + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (local.get $end) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; RTRIP: (func $slice-end-get (type $0) (result stringref) + ;; RTRIP-NEXT: (local $end i32) + ;; RTRIP-NEXT: (local $1 i32) + ;; RTRIP-NEXT: (local $2 (ref string)) + ;; RTRIP-NEXT: (stringview_wtf16.slice + ;; RTRIP-NEXT: (block (result (ref string)) + ;; RTRIP-NEXT: (local.set $2 + ;; RTRIP-NEXT: (string.const "abc") + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.set $1 + ;; RTRIP-NEXT: (i32.const 1) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.get $2) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (local.get $1) + ;; RTRIP-NEXT: (local.get $end) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RRTRP: (func $slice-end-get (type $0) (result stringref) + ;; RRTRP-NEXT: (local $end i32) + ;; RRTRP-NEXT: (local $1 i32) + ;; RRTRP-NEXT: (local $2 (ref string)) + ;; RRTRP-NEXT: (local $3 (ref string)) + ;; RRTRP-NEXT: (stringview_wtf16.slice + ;; RRTRP-NEXT: (block (result (ref string)) + ;; RRTRP-NEXT: (local.set $3 + ;; RRTRP-NEXT: (string.const "abc") + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.set $1 + ;; RRTRP-NEXT: (i32.const 1) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.get $3) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: (local.get $1) + ;; RRTRP-NEXT: (local.get $end) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: ) + (func $slice-end-get (result stringref) + (local $end i32) + (stringview_wtf16.slice + (string.const "abc") + (i32.const 1) + (local.get $end) + ) + ) + + ;; CHECK: (func $slice-both-get (type $0) (result stringref) + ;; CHECK-NEXT: (local $start i32) + ;; CHECK-NEXT: (local $end i32) + ;; CHECK-NEXT: (stringview_wtf16.slice + ;; CHECK-NEXT: (string.const "abc") + ;; CHECK-NEXT: (local.get $start) + ;; CHECK-NEXT: (local.get $end) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; RTRIP: (func $slice-both-get (type $0) (result stringref) + ;; RTRIP-NEXT: (local $start i32) + ;; RTRIP-NEXT: (local $end i32) + ;; RTRIP-NEXT: (stringview_wtf16.slice + ;; RTRIP-NEXT: (string.const "abc") + ;; RTRIP-NEXT: (local.get $start) + ;; RTRIP-NEXT: (local.get $end) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RRTRP: (func $slice-both-get (type $0) (result stringref) + ;; RRTRP-NEXT: (local $start i32) + ;; RRTRP-NEXT: (local $end i32) + ;; RRTRP-NEXT: (stringview_wtf16.slice + ;; RRTRP-NEXT: (string.const "abc") + ;; RRTRP-NEXT: (local.get $start) + ;; RRTRP-NEXT: (local.get $end) + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: ) + (func $slice-both-get (result stringref) + (local $start i32) + (local $end i32) + (stringview_wtf16.slice + (string.const "abc") + (local.get $start) + (local.get $end) + ) + ) + + ;; CHECK: (func $length (type $1) (result i32) + ;; CHECK-NEXT: (string.measure_wtf16 + ;; CHECK-NEXT: (string.const "abc") + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; RTRIP: (func $length (type $1) (result i32) + ;; RTRIP-NEXT: (string.measure_wtf16 + ;; RTRIP-NEXT: (string.const "abc") + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RRTRP: (func $length (type $1) (result i32) + ;; RRTRP-NEXT: (string.measure_wtf16 + ;; RRTRP-NEXT: (string.const "abc") + ;; RRTRP-NEXT: ) + ;; RRTRP-NEXT: ) + (func $length (result i32) + ;; This should be parsed as string.measure_wtf16 instead. + (stringview_wtf16.length + (string.as_wtf16 + (string.const "abc") + ) + ) + ) +) diff --git a/test/lit/strings.wast b/test/lit/strings.wast index 1166f13d0..c06a3ead4 100644 --- a/test/lit/strings.wast +++ b/test/lit/strings.wast @@ -18,35 +18,31 @@ ;; CHECK: (type $1 (func (param stringref stringref))) - ;; CHECK: (type $2 (func (param stringref stringview_wtf8 stringview_wtf16 stringview_iter))) - ;; CHECK: (type $array (sub (array (mut i8)))) (type $array (sub (array (mut i8)))) ;; CHECK: (type $array16 (sub (array (mut i16)))) (type $array16 (sub (array (mut i16)))) - ;; CHECK: (type $5 (func (param stringref stringview_wtf8 stringview_wtf16 stringview_iter stringref stringview_wtf8 stringview_wtf16 stringview_iter (ref string) (ref stringview_wtf8) (ref stringview_wtf16) (ref stringview_iter)))) - - ;; CHECK: (type $6 (func (param (ref string)))) + ;; CHECK: (type $4 (func (param stringref stringref (ref string)))) - ;; CHECK: (type $7 (func (param stringview_wtf16))) + ;; CHECK: (type $5 (func (param (ref string)))) - ;; CHECK: (type $8 (func (param (ref $array) (ref $array16)))) + ;; CHECK: (type $6 (func (param (ref $array) (ref $array16)))) - ;; CHECK: (type $9 (func (param stringref (ref $array) (ref $array16)))) + ;; CHECK: (type $7 (func (param stringref (ref $array) (ref $array16)))) - ;; CHECK: (type $10 (func)) + ;; CHECK: (type $8 (func)) - ;; CHECK: (type $11 (func (param (ref $array)))) + ;; CHECK: (type $9 (func (param (ref $array)))) - ;; CHECK: (type $12 (func (param stringref) (result i32))) + ;; CHECK: (type $10 (func (param stringref) (result i32))) ;; CHECK: (global $string-const stringref (string.const "string in a global \c2\a3_\e2\82\ac_\f0\90\8d\88 \01\00\t\t\n\n\r\r\"\"\'\'\\\\ ")) (global $string-const stringref (string.const "string in a global \C2\A3_\E2\82\AC_\F0\90\8D\88 \01\00\t\t\n\n\r\r\"\"\'\'\\\\ ")) ;; CHECK: (memory $0 10 10) - ;; CHECK: (func $string.new (type $5) (param $a stringref) (param $b stringview_wtf8) (param $c stringview_wtf16) (param $d stringview_iter) (param $e stringref) (param $f stringview_wtf8) (param $g stringview_wtf16) (param $h stringview_iter) (param $i (ref string)) (param $j (ref stringview_wtf8)) (param $k (ref stringview_wtf16)) (param $l (ref stringview_iter)) + ;; CHECK: (func $string.new (type $4) (param $a stringref) (param $b stringref) (param $c (ref string)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (string.new_wtf16 ;; CHECK-NEXT: (i32.const 7) @@ -74,17 +70,8 @@ ;; CHECK-NEXT: ) (func $string.new (param $a stringref) - (param $b stringview_wtf8) - (param $c stringview_wtf16) - (param $d stringview_iter) - (param $e (ref null string)) - (param $f (ref null stringview_wtf8)) - (param $g (ref null stringview_wtf16)) - (param $h (ref null stringview_iter)) - (param $i (ref string)) - (param $j (ref stringview_wtf8)) - (param $k (ref stringview_wtf16)) - (param $l (ref stringview_iter)) + (param $b (ref null string)) + (param $c (ref string)) (drop (string.new_wtf16 (i32.const 7) @@ -111,7 +98,7 @@ ) ) - ;; CHECK: (func $string.const (type $6) (param $param (ref string)) + ;; CHECK: (func $string.const (type $5) (param $param (ref string)) ;; CHECK-NEXT: (call $string.const ;; CHECK-NEXT: (string.const "foo") ;; CHECK-NEXT: ) @@ -313,184 +300,7 @@ ) ) - ;; CHECK: (func $string.as (type $2) (param $a stringref) (param $b stringview_wtf8) (param $c stringview_wtf16) (param $d stringview_iter) - ;; CHECK-NEXT: (local.set $b - ;; CHECK-NEXT: (string.as_wtf8 - ;; CHECK-NEXT: (local.get $a) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $c - ;; CHECK-NEXT: (string.as_wtf16 - ;; CHECK-NEXT: (local.get $a) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $d - ;; CHECK-NEXT: (string.as_iter - ;; CHECK-NEXT: (local.get $a) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string.as - (param $a stringref) - (param $b stringview_wtf8) - (param $c stringview_wtf16) - (param $d stringview_iter) - (local.set $b ;; validate the output type - (string.as_wtf8 - (local.get $a) - ) - ) - (local.set $c - (string.as_wtf16 - (local.get $a) - ) - ) - (local.set $d - (string.as_iter - (local.get $a) - ) - ) - ) - - ;; CHECK: (func $stringview-access (type $2) (param $a stringref) (param $b stringview_wtf8) (param $c stringview_wtf16) (param $d stringview_iter) - ;; CHECK-NEXT: (local $i32 i32) - ;; CHECK-NEXT: (local.set $i32 - ;; CHECK-NEXT: (stringview_wtf8.advance - ;; CHECK-NEXT: (local.get $b) - ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: (i32.const 1) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $i32 - ;; CHECK-NEXT: (stringview_wtf16.get_codeunit - ;; CHECK-NEXT: (local.get $c) - ;; CHECK-NEXT: (i32.const 2) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $i32 - ;; CHECK-NEXT: (stringview_iter.next - ;; CHECK-NEXT: (local.get $d) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $i32 - ;; CHECK-NEXT: (stringview_iter.advance - ;; CHECK-NEXT: (local.get $d) - ;; CHECK-NEXT: (i32.const 3) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $i32 - ;; CHECK-NEXT: (stringview_iter.rewind - ;; CHECK-NEXT: (local.get $d) - ;; CHECK-NEXT: (i32.const 4) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $stringview-access - (param $a stringref) - (param $b stringview_wtf8) - (param $c stringview_wtf16) - (param $d stringview_iter) - (local $i32 i32) - (local.set $i32 ;; validate the output type - (stringview_wtf8.advance - (local.get $b) - (i32.const 0) - (i32.const 1) - ) - ) - (local.set $i32 - (stringview_wtf16.get_codeunit - (local.get $c) - (i32.const 2) - ) - ) - (local.set $i32 - (stringview_iter.next - (local.get $d) - ) - ) - (local.set $i32 - (stringview_iter.advance - (local.get $d) - (i32.const 3) - ) - ) - (local.set $i32 - (stringview_iter.rewind - (local.get $d) - (i32.const 4) - ) - ) - ) - ;; CHECK: (func $stringview-slice (type $2) (param $a stringref) (param $b stringview_wtf8) (param $c stringview_wtf16) (param $d stringview_iter) - ;; CHECK-NEXT: (local.set $a - ;; CHECK-NEXT: (stringview_wtf8.slice - ;; CHECK-NEXT: (local.get $b) - ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: (i32.const 1) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $a - ;; CHECK-NEXT: (stringview_wtf16.slice - ;; CHECK-NEXT: (local.get $c) - ;; CHECK-NEXT: (i32.const 2) - ;; CHECK-NEXT: (i32.const 3) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $a - ;; CHECK-NEXT: (stringview_iter.slice - ;; CHECK-NEXT: (local.get $d) - ;; CHECK-NEXT: (i32.const 4) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $stringview-slice - (param $a stringref) - (param $b stringview_wtf8) - (param $c stringview_wtf16) - (param $d stringview_iter) - (local.set $a ;; validate the output type - (stringview_wtf8.slice - (local.get $b) - (i32.const 0) - (i32.const 1) - ) - ) - (local.set $a - (stringview_wtf16.slice - (local.get $c) - (i32.const 2) - (i32.const 3) - ) - ) - (local.set $a - (stringview_iter.slice - (local.get $d) - (i32.const 4) - ) - ) - ) - - ;; CHECK: (func $string.length (type $7) (param $ref stringview_wtf16) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (i32.eqz - ;; CHECK-NEXT: (stringview_wtf16.length - ;; CHECK-NEXT: (local.get $ref) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string.length (param $ref stringview_wtf16) - (drop - (i32.eqz ;; validate the output is i32 - (stringview_wtf16.length - (local.get $ref) - ) - ) - ) - ) - - ;; CHECK: (func $string.new.gc (type $8) (param $array (ref $array)) (param $array16 (ref $array16)) + ;; CHECK: (func $string.new.gc (type $6) (param $array (ref $array)) (param $array16 (ref $array16)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (string.new_wtf16_array ;; CHECK-NEXT: (local.get $array16) @@ -551,7 +361,7 @@ ) ) - ;; CHECK: (func $string.encode.gc (type $9) (param $ref stringref) (param $array (ref $array)) (param $array16 (ref $array16)) + ;; CHECK: (func $string.encode.gc (type $7) (param $ref stringref) (param $array (ref $array)) (param $array16 (ref $array16)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (string.encode_wtf16_array @@ -616,7 +426,7 @@ ) ) - ;; CHECK: (func $string.from_code_point (type $10) + ;; CHECK: (func $string.from_code_point (type $8) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (string.from_code_point ;; CHECK-NEXT: (i32.const 1) @@ -631,7 +441,7 @@ ) ) - ;; CHECK: (func $string.new_try (type $11) (param $array (ref $array)) + ;; CHECK: (func $string.new_try (type $9) (param $array (ref $array)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (string.new_utf8_try ;; CHECK-NEXT: (i32.const 1) @@ -662,7 +472,7 @@ ) ) - ;; CHECK: (func $string.hash (type $12) (param $ref stringref) (result i32) + ;; CHECK: (func $string.hash (type $10) (param $ref stringref) (result i32) ;; CHECK-NEXT: (string.hash ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast index f778b6a63..68c881a62 100644 --- a/test/lit/wat-kitchen-sink.wast +++ b/test/lit/wat-kitchen-sink.wast @@ -168,41 +168,23 @@ ;; CHECK: (type $77 (func (param stringref) (result i32))) - ;; CHECK: (type $78 (func (param stringview_wtf16) (result i32))) + ;; CHECK: (type $78 (func (param stringref (ref $packed-i8) i32) (result i32))) - ;; CHECK: (type $79 (func (param stringref (ref $packed-i8) i32) (result i32))) + ;; CHECK: (type $79 (func (param stringref stringref) (result (ref string)))) - ;; CHECK: (type $80 (func (param stringref stringref) (result (ref string)))) + ;; CHECK: (type $80 (func (param stringref i32) (result i32))) - ;; CHECK: (type $81 (func (param stringref) (result stringview_wtf8))) + ;; CHECK: (type $81 (func (param stringref i32 i32) (result (ref string)))) - ;; CHECK: (type $82 (func (param stringref) (result (ref stringview_wtf16)))) - - ;; CHECK: (type $83 (func (param stringref) (result stringview_iter))) - - ;; CHECK: (type $84 (func (param (ref stringview_wtf8) i32 i32) (result i32))) - - ;; CHECK: (type $85 (func (param stringview_wtf16 i32) (result i32))) - - ;; CHECK: (type $86 (func (param stringview_iter) (result i32))) - - ;; CHECK: (type $87 (func (param stringview_iter i32) (result i32))) - - ;; CHECK: (type $88 (func (param (ref stringview_iter) i32) (result i32))) - - ;; CHECK: (type $89 (func (param stringview_wtf8 stringview_wtf16 i32 i32))) - - ;; CHECK: (type $90 (func (param stringview_iter i32) (result (ref string)))) - - ;; CHECK: (type $91 (func (param (ref $simple-cont)))) + ;; CHECK: (type $82 (func (param (ref $simple-cont)))) ;; CHECK: (type $to-f32 (func (result f32))) ;; CHECK: (type $to-f32-cont (cont $to-f32)) - ;; CHECK: (type $94 (func (param (ref $simple)) (result (ref $simple-cont)))) + ;; CHECK: (type $85 (func (param (ref $simple)) (result (ref $simple-cont)))) - ;; CHECK: (type $95 (func (param (ref $cont-bind-before)) (result (ref $simple-cont)))) + ;; CHECK: (type $86 (func (param (ref $cont-bind-before)) (result (ref $simple-cont)))) ;; CHECK: (type $s2 (struct (field i32))) (type $s2 (struct i32)) @@ -256,7 +238,7 @@ (type $cont-bind-before-func (func (param i32) (param i64) (param i32) (param i64) (result f32))) (type $cont-bind-before (cont $cont-bind-before-func)) - ;; CHECK: (type $all-types (struct (field externref) (field (ref extern)) (field funcref) (field (ref func)) (field anyref) (field (ref any)) (field eqref) (field (ref eq)) (field i31ref) (field (ref i31)) (field structref) (field (ref struct)) (field arrayref) (field (ref array)) (field exnref) (field (ref exn)) (field stringref) (field (ref string)) (field stringview_wtf8) (field (ref stringview_wtf8)) (field stringview_wtf16) (field (ref stringview_wtf16)) (field stringview_iter) (field (ref stringview_iter)) (field contref) (field (ref cont)) (field nullref) (field (ref none)) (field nullexternref) (field (ref noextern)) (field nullfuncref) (field (ref nofunc)) (field nullexnref) (field (ref noexn)) (field nullcontref) (field (ref nocont)))) + ;; CHECK: (type $all-types (struct (field externref) (field (ref extern)) (field funcref) (field (ref func)) (field anyref) (field (ref any)) (field eqref) (field (ref eq)) (field i31ref) (field (ref i31)) (field structref) (field (ref struct)) (field arrayref) (field (ref array)) (field exnref) (field (ref exn)) (field stringref) (field (ref string)) (field contref) (field (ref cont)) (field nullref) (field (ref none)) (field nullexternref) (field (ref noextern)) (field nullfuncref) (field (ref nofunc)) (field nullexnref) (field (ref noexn)) (field nullcontref) (field (ref nocont)))) (type $all-types (struct externref (ref extern) funcref (ref func) anyref (ref any) @@ -266,9 +248,6 @@ arrayref (ref array) exnref (ref exn) stringref (ref string) - stringview_wtf8 (ref stringview_wtf8) - stringview_wtf16 (ref stringview_wtf16) - stringview_iter (ref stringview_iter) contref (ref cont) nullref (ref none) nullexternref (ref noextern) @@ -278,7 +257,7 @@ ;; imported memories (memory (export "mem") (export "mem2") (import "" "mem") 0) - ;; CHECK: (type $107 (func (param (ref $s0) (ref $s1) (ref $s2) (ref $s3) (ref $s4) (ref $s5) (ref $s6) (ref $s7) (ref $s8) (ref $a0) (ref $a1) (ref $a2) (ref $a3) (ref $subvoid) (ref $submany) (ref $all-types)))) + ;; CHECK: (type $98 (func (param (ref $s0) (ref $s1) (ref $s2) (ref $s3) (ref $s4) (ref $s5) (ref $s6) (ref $s7) (ref $s8) (ref $a0) (ref $a1) (ref $a2) (ref $a3) (ref $subvoid) (ref $submany) (ref $all-types)))) ;; CHECK: (import "" "mem" (memory $mimport$0 0)) @@ -4554,16 +4533,6 @@ string.hash ) - ;; CHECK: (func $stringview-length (type $78) (param $0 stringview_wtf16) (result i32) - ;; CHECK-NEXT: (stringview_wtf16.length - ;; CHECK-NEXT: (local.get $0) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $stringview-length (param stringview_wtf16) (result i32) - local.get 0 - stringview_wtf16.length - ) - ;; CHECK: (func $string-encode (type $29) (param $0 stringref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (string.encode_wtf8 @@ -4609,7 +4578,7 @@ drop ) - ;; CHECK: (func $string-encode-gc (type $79) (param $0 stringref) (param $1 (ref $packed-i8)) (param $2 i32) (result i32) + ;; CHECK: (func $string-encode-gc (type $78) (param $0 stringref) (param $1 (ref $packed-i8)) (param $2 i32) (result i32) ;; CHECK-NEXT: (string.encode_wtf8_array ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -4623,7 +4592,7 @@ string.encode_wtf8_array ) - ;; CHECK: (func $string-concat (type $80) (param $0 stringref) (param $1 stringref) (result (ref string)) + ;; CHECK: (func $string-concat (type $79) (param $0 stringref) (param $1 stringref) (result (ref string)) ;; CHECK-NEXT: (string.concat ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) @@ -4659,135 +4628,30 @@ string.compare ) - ;; CHECK: (func $string-as-wtf8 (type $81) (param $0 stringref) (result stringview_wtf8) - ;; CHECK-NEXT: (string.as_wtf8 - ;; CHECK-NEXT: (local.get $0) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string-as-wtf8 (param stringref) (result stringview_wtf8) - local.get 0 - string.as_wtf8 - ) - - ;; CHECK: (func $string-as-wtf16 (type $82) (param $0 stringref) (result (ref stringview_wtf16)) - ;; CHECK-NEXT: (string.as_wtf16 - ;; CHECK-NEXT: (local.get $0) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string-as-wtf16 (param stringref) (result (ref stringview_wtf16)) - local.get 0 - string.as_wtf16 - ) - - ;; CHECK: (func $string-as-iter (type $83) (param $0 stringref) (result stringview_iter) - ;; CHECK-NEXT: (string.as_iter - ;; CHECK-NEXT: (local.get $0) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string-as-iter (param stringref) (result stringview_iter) - local.get 0 - string.as_iter - ) - - ;; CHECK: (func $string-advance (type $84) (param $0 (ref stringview_wtf8)) (param $1 i32) (param $2 i32) (result i32) - ;; CHECK-NEXT: (stringview_wtf8.advance - ;; CHECK-NEXT: (local.get $0) - ;; CHECK-NEXT: (local.get $1) - ;; CHECK-NEXT: (local.get $2) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string-advance (param (ref stringview_wtf8) i32 i32) (result i32) - local.get 0 - local.get 1 - local.get 2 - stringview_wtf8.advance - ) - - ;; CHECK: (func $string-get (type $85) (param $0 stringview_wtf16) (param $1 i32) (result i32) + ;; CHECK: (func $string-get (type $80) (param $0 stringref) (param $1 i32) (result i32) ;; CHECK-NEXT: (stringview_wtf16.get_codeunit ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $string-get (param stringview_wtf16 i32) (result i32) + (func $string-get (param stringref i32) (result i32) local.get 0 local.get 1 stringview_wtf16.get_codeunit ) - ;; CHECK: (func $string-iter-next (type $86) (param $0 stringview_iter) (result i32) - ;; CHECK-NEXT: (stringview_iter.next - ;; CHECK-NEXT: (local.get $0) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string-iter-next (param stringview_iter) (result i32) - local.get 0 - stringview_iter.next - ) - - ;; CHECK: (func $string-iter-advance (type $87) (param $0 stringview_iter) (param $1 i32) (result i32) - ;; CHECK-NEXT: (stringview_iter.advance - ;; CHECK-NEXT: (local.get $0) - ;; CHECK-NEXT: (local.get $1) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string-iter-advance (param (ref null stringview_iter) i32) (result i32) - local.get 0 - local.get 1 - stringview_iter.advance - ) - - ;; CHECK: (func $string-iter-rewind (type $88) (param $0 (ref stringview_iter)) (param $1 i32) (result i32) - ;; CHECK-NEXT: (stringview_iter.rewind + ;; CHECK: (func $string-slice (type $81) (param $0 stringref) (param $1 i32) (param $2 i32) (result (ref string)) + ;; CHECK-NEXT: (stringview_wtf16.slice ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $string-iter-rewind (param (ref stringview_iter) i32) (result i32) - local.get 0 - local.get 1 - stringview_iter.rewind - ) - - ;; CHECK: (func $string-slice (type $89) (param $0 stringview_wtf8) (param $1 stringview_wtf16) (param $2 i32) (param $3 i32) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (stringview_wtf8.slice - ;; CHECK-NEXT: (local.get $0) - ;; CHECK-NEXT: (local.get $2) - ;; CHECK-NEXT: (local.get $3) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (stringview_wtf16.slice - ;; CHECK-NEXT: (local.get $1) - ;; CHECK-NEXT: (local.get $2) - ;; CHECK-NEXT: (local.get $3) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string-slice (param stringview_wtf8 stringview_wtf16 i32 i32) + (func $string-slice (param stringref i32 i32) (result (ref string)) local.get 0 - local.get 2 - local.get 3 - stringview_wtf8.slice - drop local.get 1 local.get 2 - local.get 3 stringview_wtf16.slice - drop - ) - - ;; CHECK: (func $string-iter-slice (type $90) (param $0 stringview_iter) (param $1 i32) (result (ref string)) - ;; CHECK-NEXT: (stringview_iter.slice - ;; CHECK-NEXT: (local.get $0) - ;; CHECK-NEXT: (local.get $1) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $string-iter-slice (param stringview_iter i32) (result (ref string)) - local.get 0 - local.get 1 - stringview_iter.slice ) ;; CHECK: (func $call (type $simple) (param $0 i32) (param $1 i64) (result f32) @@ -5077,7 +4941,7 @@ ) ) - ;; CHECK: (func $resume (type $91) (param $ct (ref $simple-cont)) + ;; CHECK: (func $resume (type $82) (param $ct (ref $simple-cont)) ;; CHECK-NEXT: (local $f f32) ;; CHECK-NEXT: (block $label ;; CHECK-NEXT: (drop @@ -5116,7 +4980,7 @@ br 0 ) - ;; CHECK: (func $contnew (type $94) (param $f (ref $simple)) (result (ref $simple-cont)) + ;; CHECK: (func $contnew (type $85) (param $f (ref $simple)) (result (ref $simple-cont)) ;; CHECK-NEXT: (cont.new $simple-cont ;; CHECK-NEXT: (local.get $f) ;; CHECK-NEXT: ) @@ -5126,7 +4990,7 @@ cont.new $simple-cont ) - ;; CHECK: (func $contbind (type $95) (param $c (ref $cont-bind-before)) (result (ref $simple-cont)) + ;; CHECK: (func $contbind (type $86) (param $c (ref $cont-bind-before)) (result (ref $simple-cont)) ;; CHECK-NEXT: (cont.bind $cont-bind-before $simple-cont ;; CHECK-NEXT: (i32.const 123) ;; CHECK-NEXT: (i64.const 123) @@ -5251,7 +5115,7 @@ drop ) - ;; CHECK: (func $use-types (type $107) (param $0 (ref $s0)) (param $1 (ref $s1)) (param $2 (ref $s2)) (param $3 (ref $s3)) (param $4 (ref $s4)) (param $5 (ref $s5)) (param $6 (ref $s6)) (param $7 (ref $s7)) (param $8 (ref $s8)) (param $9 (ref $a0)) (param $10 (ref $a1)) (param $11 (ref $a2)) (param $12 (ref $a3)) (param $13 (ref $subvoid)) (param $14 (ref $submany)) (param $15 (ref $all-types)) + ;; CHECK: (func $use-types (type $98) (param $0 (ref $s0)) (param $1 (ref $s1)) (param $2 (ref $s2)) (param $3 (ref $s3)) (param $4 (ref $s4)) (param $5 (ref $s5)) (param $6 (ref $s6)) (param $7 (ref $s7)) (param $8 (ref $s8)) (param $9 (ref $a0)) (param $10 (ref $a1)) (param $11 (ref $a2)) (param $12 (ref $a3)) (param $13 (ref $subvoid)) (param $14 (ref $submany)) (param $15 (ref $all-types)) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $use-types |