diff options
author | Thomas Lively <tlively@google.com> | 2023-09-13 20:02:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-13 20:02:26 -0700 |
commit | 2cbe448eb4df17010f0e5f360a8e705da710f3e0 (patch) | |
tree | b0967cb40dd4dbb2d209afb66cdf58c8af498cf9 | |
parent | 9d79632c210a8c5002657ae87ff06c70ee109e8f (diff) | |
download | binaryen-2cbe448eb4df17010f0e5f360a8e705da710f3e0.tar.gz binaryen-2cbe448eb4df17010f0e5f360a8e705da710f3e0.tar.bz2 binaryen-2cbe448eb4df17010f0e5f360a8e705da710f3e0.zip |
Replace i31.new with ref.i31 everywhere (#5931)
Replace i31.new with ref.i31 in the printer, tests, and source code. Continue
parsing i31.new for the time being to allow a graceful transition. Also update
the JS API to reflect the new instruction name.
40 files changed, 183 insertions, 142 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ad9af6b3..80fefc4c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,9 @@ full changeset diff at the end of each section. Current Trunk ------------- - - "I31New" changed to "RefI31" everywhere it appears in the C API. + - "I31New" changed to "RefI31" everywhere it appears in the C API and similarly + "i31.new" has been replaced with "ref.i31" in the JS API and in printed + output. v115 ---- diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py index e4cd642ca..2fd663510 100755 --- a/scripts/gen-s-parser.py +++ b/scripts/gen-s-parser.py @@ -564,7 +564,8 @@ instructions = [ ("call_ref", "makeCallRef(s, /*isReturn=*/false)"), ("return_call_ref", "makeCallRef(s, /*isReturn=*/true)"), # GC - ("i31.new", "makeRefI31(s)"), + ("i31.new", "makeRefI31(s)"), # deprecated + ("ref.i31", "makeRefI31(s)"), ("i31.get_s", "makeI31Get(s, true)"), ("i31.get_u", "makeI31Get(s, false)"), ("ref.test", "makeRefTest(s)"), diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 4321ec452..d16f46d9a 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -2308,10 +2308,10 @@ BINARYEN_API void BinaryenTupleExtractSetIndex(BinaryenExpressionRef expr, // RefI31 -// Gets the value expression of an `i31.new` expression. +// Gets the value expression of a `ref.i31` expression. BINARYEN_API BinaryenExpressionRef BinaryenRefI31GetValue(BinaryenExpressionRef expr); -// Sets the value expression of an `i31.new` expression. +// Sets the value expression of a `ref.i31` expression. BINARYEN_API void BinaryenRefI31SetValue(BinaryenExpressionRef expr, BinaryenExpressionRef valueExpr); diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc index 5b812c6d1..506ec62ad 100644 --- a/src/gen-s-parser.inc +++ b/src/gen-s-parser.inc @@ -2984,9 +2984,17 @@ switch (buf[0]) { case 'f': if (op == "ref.func"sv) { return makeRefFunc(s); } goto parse_error; - case 'i': - if (op == "ref.is_null"sv) { return makeRefIsNull(s); } - goto parse_error; + case 'i': { + switch (buf[5]) { + case '3': + if (op == "ref.i31"sv) { return makeRefI31(s); } + goto parse_error; + case 's': + if (op == "ref.is_null"sv) { return makeRefIsNull(s); } + goto parse_error; + default: goto parse_error; + } + } case 'n': if (op == "ref.null"sv) { return makeRefNull(s); } goto parse_error; @@ -8585,13 +8593,25 @@ switch (buf[0]) { return *ret; } goto parse_error; - case 'i': - if (op == "ref.is_null"sv) { - auto ret = makeRefIsNull(ctx, pos); - CHECK_ERR(ret); - return *ret; + case 'i': { + switch (buf[5]) { + case '3': + if (op == "ref.i31"sv) { + auto ret = makeRefI31(ctx, pos); + CHECK_ERR(ret); + return *ret; + } + goto parse_error; + case 's': + if (op == "ref.is_null"sv) { + auto ret = makeRefIsNull(ctx, pos); + CHECK_ERR(ret); + return *ret; + } + goto parse_error; + default: goto parse_error; } - goto parse_error; + } case 'n': if (op == "ref.null"sv) { auto ret = makeRefNull(ctx, pos); diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index b6ea4d490..4ff719b30 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -2370,6 +2370,9 @@ function wrapModule(module, self = {}) { 'func'(func, type) { return preserveStack(() => Module['_BinaryenRefFunc'](module, strToStack(func), type)); }, + 'i31'(value) { + return Module['_BinaryenRefI31'](module, value); + }, 'eq'(left, right) { return Module['_BinaryenRefEq'](module, left, right); } @@ -2418,9 +2421,6 @@ function wrapModule(module, self = {}) { }; self['i31'] = { - 'new'(value) { - return Module['_BinaryenRefI31'](module, value); - }, 'get_s'(i31) { return Module['_BinaryenI31Get'](module, i31, 1); }, diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 203d922d0..c47f33944 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1959,7 +1959,7 @@ struct PrintExpressionContents printMedium(o, "tuple.extract "); o << curr->index; } - void visitRefI31(RefI31* curr) { printMedium(o, "i31.new"); } + void visitRefI31(RefI31* curr) { printMedium(o, "ref.i31"); } void visitI31Get(I31Get* curr) { printMedium(o, curr->signed_ ? "i31.get_s" : "i31.get_u"); } diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index a5950f2fa..fca5b7db4 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -732,7 +732,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { // // (br_on_cast $l anyref i31ref // (block (result anyref) - // (i31.new ...))) + // (ref.i31 ...))) // // We could just always do the cast and leave removing the casts to // OptimizeInstructions, but it's simple enough to avoid unnecessary diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 1aa52e70d..f776c1c9d 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -2321,7 +2321,7 @@ Expression* TranslateToFuzzReader::makeBasicRef(Type type) { return builder.makeRefNull(HeapType::none); } auto nullability = getSubType(type.getNullability()); - // i31.new is not allowed in initializer expressions. + // ref.i31 is not allowed in initializer expressions. HeapType subtype; switch (upTo(3)) { case 0: diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 0d45a4773..c1836a7ff 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2504,11 +2504,11 @@ void FunctionValidator::visitCallRef(CallRef* curr) { void FunctionValidator::visitRefI31(RefI31* curr) { shouldBeTrue( - getModule()->features.hasGC(), curr, "i31.new requires gc [--enable-gc]"); + getModule()->features.hasGC(), curr, "ref.i31 requires gc [--enable-gc]"); shouldBeSubType(curr->value->type, Type::i32, curr->value, - "i31.new's argument should be i32"); + "ref.i31's argument should be i32"); } void FunctionValidator::visitI31Get(I31Get* curr) { diff --git a/test/binaryen.js/expressions.js b/test/binaryen.js/expressions.js index 83e005f0d..e5ad3567e 100644 --- a/test/binaryen.js/expressions.js +++ b/test/binaryen.js/expressions.js @@ -1776,7 +1776,7 @@ console.log("# RefI31"); const module = new binaryen.Module(); var value = module.local.get(1, binaryen.i32); - const theRefI31 = binaryen.RefI31(module.i31.new(value)); + const theRefI31 = binaryen.RefI31(module.ref.i31(value)); assert(theRefI31 instanceof binaryen.RefI31); assert(theRefI31 instanceof binaryen.Expression); assert(theRefI31.value === value); @@ -1792,7 +1792,7 @@ console.log("# RefI31"); assert( theRefI31.toText() == - "(i31.new\n (local.get $2)\n)\n" + "(ref.i31\n (local.get $2)\n)\n" ); module.dispose(); diff --git a/test/binaryen.js/expressions.js.txt b/test/binaryen.js/expressions.js.txt index 01ef40f70..96d22f51e 100644 --- a/test/binaryen.js/expressions.js.txt +++ b/test/binaryen.js/expressions.js.txt @@ -331,7 +331,7 @@ ) # RefI31 -(i31.new +(ref.i31 (local.get $2) ) diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index ecc20448f..235d09f3e 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -669,16 +669,16 @@ function test_core() { module.memory.grow(makeInt32(0)), // GC - module.i31.new( + module.ref.i31( module.i32.const(0) ), module.i31.get_s( - module.i31.new( + module.ref.i31( module.i32.const(1) ) ), module.i31.get_u( - module.i31.new( + module.ref.i31( module.i32.const(2) ) ), diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index ce0150f81..e8cb7e0ab 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -2202,20 +2202,20 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) ) (drop - (i31.new + (ref.i31 (i32.const 0) ) ) (drop (i31.get_s - (i31.new + (ref.i31 (i32.const 1) ) ) ) (drop (i31.get_u - (i31.new + (ref.i31 (i32.const 2) ) ) @@ -4306,20 +4306,20 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) ) (drop - (i31.new + (ref.i31 (i32.const 0) ) ) (drop (i31.get_s - (i31.new + (ref.i31 (i32.const 1) ) ) ) (drop (i31.get_u - (i31.new + (ref.i31 (i32.const 2) ) ) diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index d84e9c888..f7df65f71 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -2241,20 +2241,20 @@ BinaryenFeatureAll: 65535 ) ) (drop - (i31.new + (ref.i31 (i32.const 0) ) ) (drop (i31.get_s - (i31.new + (ref.i31 (i32.const 1) ) ) ) (drop (i31.get_u - (i31.new + (ref.i31 (i32.const 2) ) ) diff --git a/test/gc.wast.from-wast b/test/gc.wast.from-wast index 40b870dca..38f7eb9f6 100644 --- a/test/gc.wast.from-wast +++ b/test/gc.wast.from-wast @@ -3,14 +3,14 @@ (type $i31ref_ref|i31|_structref_ref|struct|_=>_none (func (param i31ref (ref i31) structref (ref struct)))) (global $global_anyref (mut anyref) (ref.null none)) (global $global_eqref (mut eqref) (ref.null none)) - (global $global_i31ref (mut i31ref) (i31.new + (global $global_i31ref (mut i31ref) (ref.i31 (i32.const 0) )) (global $global_anyref2 (mut anyref) (ref.null none)) - (global $global_anyref3 (mut anyref) (i31.new + (global $global_anyref3 (mut anyref) (ref.i31 (i32.const 0) )) - (global $global_eqref2 (mut eqref) (i31.new + (global $global_eqref2 (mut eqref) (ref.i31 (i32.const 0) )) (func $test (type $i31ref_structref_=>_none) (param $local_i31ref i31ref) (param $local_structref structref) @@ -42,7 +42,7 @@ (global.get $global_i31ref) ) (local.set $local_i31ref - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -62,7 +62,7 @@ (global.get $global_i31ref) ) (local.set $local_anyref - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -73,7 +73,7 @@ (global.get $global_i31ref) ) (local.set $local_eqref - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -102,7 +102,7 @@ (global.get $global_i31ref) ) (global.set $global_i31ref - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -122,7 +122,7 @@ (global.get $global_i31ref) ) (global.set $global_anyref - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -133,7 +133,7 @@ (global.get $global_i31ref) ) (global.set $global_eqref - (i31.new + (ref.i31 (i32.const 0) ) ) diff --git a/test/gc.wast.fromBinary b/test/gc.wast.fromBinary index d37e4b741..8e5f11a0c 100644 --- a/test/gc.wast.fromBinary +++ b/test/gc.wast.fromBinary @@ -3,14 +3,14 @@ (type $i31ref_ref|i31|_structref_ref|struct|_=>_none (func (param i31ref (ref i31) structref (ref struct)))) (global $global_anyref (mut anyref) (ref.null none)) (global $global_eqref (mut eqref) (ref.null none)) - (global $global_i31ref (mut i31ref) (i31.new + (global $global_i31ref (mut i31ref) (ref.i31 (i32.const 0) )) (global $global_anyref2 (mut anyref) (ref.null none)) - (global $global_anyref3 (mut anyref) (i31.new + (global $global_anyref3 (mut anyref) (ref.i31 (i32.const 0) )) - (global $global_eqref2 (mut eqref) (i31.new + (global $global_eqref2 (mut eqref) (ref.i31 (i32.const 0) )) (func $test (type $i31ref_structref_=>_none) (param $local_i31ref i31ref) (param $local_structref structref) @@ -42,7 +42,7 @@ (global.get $global_i31ref) ) (local.set $local_i31ref - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -62,7 +62,7 @@ (global.get $global_i31ref) ) (local.set $local_anyref - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -73,7 +73,7 @@ (global.get $global_i31ref) ) (local.set $local_eqref - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -102,7 +102,7 @@ (global.get $global_i31ref) ) (global.set $global_i31ref - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -122,7 +122,7 @@ (global.get $global_i31ref) ) (global.set $global_anyref - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -133,7 +133,7 @@ (global.get $global_i31ref) ) (global.set $global_eqref - (i31.new + (ref.i31 (i32.const 0) ) ) diff --git a/test/gc.wast.fromBinary.noDebugInfo b/test/gc.wast.fromBinary.noDebugInfo index b9cc6b04a..64f11cfaf 100644 --- a/test/gc.wast.fromBinary.noDebugInfo +++ b/test/gc.wast.fromBinary.noDebugInfo @@ -3,14 +3,14 @@ (type $i31ref_ref|i31|_structref_ref|struct|_=>_none (func (param i31ref (ref i31) structref (ref struct)))) (global $global$0 (mut anyref) (ref.null none)) (global $global$1 (mut eqref) (ref.null none)) - (global $global$2 (mut i31ref) (i31.new + (global $global$2 (mut i31ref) (ref.i31 (i32.const 0) )) (global $global$3 (mut anyref) (ref.null none)) - (global $global$4 (mut anyref) (i31.new + (global $global$4 (mut anyref) (ref.i31 (i32.const 0) )) - (global $global$5 (mut eqref) (i31.new + (global $global$5 (mut eqref) (ref.i31 (i32.const 0) )) (func $0 (type $i31ref_structref_=>_none) (param $0 i31ref) (param $1 structref) @@ -42,7 +42,7 @@ (global.get $global$2) ) (local.set $0 - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -62,7 +62,7 @@ (global.get $global$2) ) (local.set $3 - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -73,7 +73,7 @@ (global.get $global$2) ) (local.set $4 - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -102,7 +102,7 @@ (global.get $global$2) ) (global.set $global$2 - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -122,7 +122,7 @@ (global.get $global$2) ) (global.set $global$0 - (i31.new + (ref.i31 (i32.const 0) ) ) @@ -133,7 +133,7 @@ (global.get $global$2) ) (global.set $global$1 - (i31.new + (ref.i31 (i32.const 0) ) ) diff --git a/test/lit/ctor-eval/extern.wast b/test/lit/ctor-eval/extern.wast index b279b718e..5bb5c8cbc 100644 --- a/test/lit/ctor-eval/extern.wast +++ b/test/lit/ctor-eval/extern.wast @@ -20,7 +20,7 @@ ;; CHECK: (global $ctor-eval$global_1 (ref $struct) (struct.new $struct ;; CHECK-NEXT: (extern.externalize - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -38,7 +38,7 @@ ;; serialization of an externalized i31 is what is written here. But the add ;; will be evalled out. (extern.externalize - (i31.new + (ref.i31 (i32.add (i32.const 41) (i32.const 1) @@ -62,7 +62,7 @@ ;; This will add a global that contains an externalization operation. (struct.new $struct (extern.externalize - (i31.new + (ref.i31 (i32.const 1) ) ) @@ -72,7 +72,7 @@ ;; CHECK: (func $test1_3 (type $2) (result externref) ;; CHECK-NEXT: (extern.externalize -;; CHECK-NEXT: (i31.new +;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 42) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) diff --git a/test/lit/exec/i31.wast b/test/lit/exec/i31.wast index c8b43e6ce..cd25dffa0 100644 --- a/test/lit/exec/i31.wast +++ b/test/lit/exec/i31.wast @@ -24,7 +24,7 @@ ;; CHECK-NEXT: [fuzz-exec] note result: non-null => 0 (func "non-null" (result i32) (ref.is_null - (i31.new + (ref.i31 (i32.const 1234) ) ) @@ -34,7 +34,7 @@ ;; CHECK-NEXT: [fuzz-exec] note result: nn-u => 2147483647 (func "nn-u" (result i32) (i31.get_u - (i31.new + (ref.i31 (i32.const 0xffffffff) ) ) @@ -44,7 +44,7 @@ ;; CHECK-NEXT: [fuzz-exec] note result: nn-s => -1 (func "nn-s" (result i32) (i31.get_s - (i31.new + (ref.i31 (i32.const 0xffffffff) ) ) @@ -55,7 +55,7 @@ (func "zero-is-not-null" (result i32) (local $ref (ref null i31)) (local.set $ref - (i31.new + (ref.i31 (i32.const 0) ) ) diff --git a/test/lit/i31-new.wast b/test/lit/i31-new.wast new file mode 100644 index 000000000..9d47b3ec9 --- /dev/null +++ b/test/lit/i31-new.wast @@ -0,0 +1,18 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. + +;; Check that we still parse the legacy i31.new instruction. + +;; RUN: wasm-opt %s -all -S -o - | filecheck %s + +(module + ;; CHECK: (func $test (type $0) (result i31ref) + ;; CHECK-NEXT: (ref.i31 + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $test (result i31ref) + (i31.new + (i32.const 0) + ) + ) +) diff --git a/test/lit/passes/coalesce-locals-gc.wast b/test/lit/passes/coalesce-locals-gc.wast index 6e3381e8e..b9224f59e 100644 --- a/test/lit/passes/coalesce-locals-gc.wast +++ b/test/lit/passes/coalesce-locals-gc.wast @@ -17,12 +17,12 @@ (global $global (ref null $array) (ref.null $array)) ;; CHECK: (global $nn-tuple-global (mut ((ref any) i32)) (tuple.make - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: )) - (global $nn-tuple-global (mut ((ref any) i32)) (tuple.make (i31.new (i32.const 0)) (i32.const 1))) + (global $nn-tuple-global (mut ((ref any) i32)) (tuple.make (ref.i31 (i32.const 0)) (i32.const 1))) ;; CHECK: (func $test-dead-get-non-nullable (type $6) (param $0 (ref struct)) @@ -160,7 +160,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result i31ref) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -230,7 +230,7 @@ ;; CHECK-NEXT: (ref.test (ref i31) ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (block (result i31ref) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/dae-gc.wast b/test/lit/passes/dae-gc.wast index 5ca1d0373..02a2462db 100644 --- a/test/lit/passes/dae-gc.wast +++ b/test/lit/passes/dae-gc.wast @@ -10,7 +10,7 @@ ;; CHECK-NEXT: ) (func $foo (call $bar - (i31.new + (ref.i31 (i32.const 1) ) ) @@ -19,7 +19,7 @@ ;; CHECK-NEXT: (local $0 i31ref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $0 - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -35,7 +35,7 @@ ;; and also add a ref.as_non_null so that the outside still receives the ;; same type as before (local.tee $0 - (i31.new + (ref.i31 (i32.const 2) ) ) @@ -134,7 +134,7 @@ ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $bar - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -149,7 +149,7 @@ ) (call $bar (ref.null none) - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) ) diff --git a/test/lit/passes/dae_all-features.wast b/test/lit/passes/dae_all-features.wast index 61591e977..dee38f646 100644 --- a/test/lit/passes/dae_all-features.wast +++ b/test/lit/passes/dae_all-features.wast @@ -542,7 +542,7 @@ ;; CHECK-NEXT: ) (func $1 (call $0 - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) ) ) diff --git a/test/lit/passes/dce_all-features.wast b/test/lit/passes/dce_all-features.wast index d79426dad..255ca82fd 100644 --- a/test/lit/passes/dce_all-features.wast +++ b/test/lit/passes/dce_all-features.wast @@ -1437,7 +1437,7 @@ ;; CHECK-NEXT: (if (result i31ref) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (unreachable) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 42) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1457,7 +1457,7 @@ (block (result i31ref) (unreachable) ) - (i31.new + (ref.i31 (i32.const 42) ) ) @@ -1473,7 +1473,7 @@ ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (catch_all - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 42) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1491,7 +1491,7 @@ ) ) (catch_all - (i31.new + (ref.i31 (i32.const 42) ) ) diff --git a/test/lit/passes/global-refining.wast b/test/lit/passes/global-refining.wast index 48538a01d..8f0b3c247 100644 --- a/test/lit/passes/global-refining.wast +++ b/test/lit/passes/global-refining.wast @@ -123,7 +123,7 @@ ;; CHECK: (func $foo (type $0) ;; CHECK-NEXT: (global.set $global - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -142,7 +142,7 @@ ;; CHECK-NEXT: ) ;; CLOSD: (func $foo (type $0) ;; CLOSD-NEXT: (global.set $global - ;; CLOSD-NEXT: (i31.new + ;; CLOSD-NEXT: (ref.i31 ;; CLOSD-NEXT: (i32.const 0) ;; CLOSD-NEXT: ) ;; CLOSD-NEXT: ) @@ -160,7 +160,7 @@ ;; CLOSD-NEXT: ) ;; CLOSD-NEXT: ) (func $foo - (global.set $global (i31.new (i32.const 0))) + (global.set $global (ref.i31 (i32.const 0))) (global.set $global (struct.new_default $struct)) (global.set $global (ref.null eq)) ;; These nulls will be updated. diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast index 0e081637b..ee125b1f2 100644 --- a/test/lit/passes/gufa-refs.wast +++ b/test/lit/passes/gufa-refs.wast @@ -2557,7 +2557,7 @@ ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (select (result i31ref) ;; CHECK-NEXT: (ref.null none) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $import) @@ -2600,7 +2600,7 @@ (ref.cast (ref null $struct) (select (ref.null $struct) - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) (call $import) ) ) @@ -3675,7 +3675,7 @@ ;; CHECK-NEXT: (local $chars (ref null $chars)) ;; CHECK-NEXT: (local.set $bytes ;; CHECK-NEXT: (array.new_fixed $bytes 1 - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -3714,7 +3714,7 @@ ;; there. (local.set $bytes (array.new_fixed $bytes 1 - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) ) (local.set $chars @@ -3763,7 +3763,7 @@ ;; CHECK-NEXT: (local $chars (ref null $chars)) ;; CHECK-NEXT: (local.set $bytes ;; CHECK-NEXT: (array.new_fixed $bytes 1 - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -3803,7 +3803,7 @@ (local $chars (ref null $chars)) (local.set $bytes (array.new_fixed $bytes 1 - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) ) (local.set $chars @@ -4125,7 +4125,7 @@ ;; CHECK: (func $i31 (type $0) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i31.get_s - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -4134,7 +4134,7 @@ (func $i31 (drop (i31.get_s - (i31.new + (ref.i31 (i32.const 0) ) ) diff --git a/test/lit/passes/local-subtyping.wast b/test/lit/passes/local-subtyping.wast index c86f4d645..3d4d392a9 100644 --- a/test/lit/passes/local-subtyping.wast +++ b/test/lit/passes/local-subtyping.wast @@ -30,10 +30,10 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (if (result (ref i31)) ;; CHECK-NEXT: (local.get $x) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -41,11 +41,11 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $block (result (ref i31)) ;; CHECK-NEXT: (br $block - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -55,16 +55,16 @@ (drop (if (result anyref) (local.get $x) - (i31.new (i32.const 0)) - (i31.new (i32.const 1)) + (ref.i31 (i32.const 0)) + (ref.i31 (i32.const 1)) ) ) (drop (block $block (result anyref) (br $block - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) - (i31.new (i32.const 1)) + (ref.i31 (i32.const 1)) ) ) ) @@ -99,7 +99,7 @@ ;; CHECK-NEXT: (local $z structref) ;; CHECK-NEXT: (local $w (ref func)) ;; CHECK-NEXT: (local.set $x - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -107,12 +107,12 @@ ;; CHECK-NEXT: (local.get $struct) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $y - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $y - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -136,17 +136,17 @@ (local $w funcref) ;; x is assigned two different types with a new LUB possible (local.set $x - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) (local.set $x (local.get $struct) ) ;; y and z are assigned the same more specific type twice (local.set $y - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) (local.set $y - (i31.new (i32.const 1)) + (ref.i31 (i32.const 1)) ) (local.set $z (local.get $struct) diff --git a/test/lit/passes/remove-unused-brs-gc.wast b/test/lit/passes/remove-unused-brs-gc.wast index 5b4e09a25..ce06b89ef 100644 --- a/test/lit/passes/remove-unused-brs-gc.wast +++ b/test/lit/passes/remove-unused-brs-gc.wast @@ -162,7 +162,7 @@ ;; CHECK-NEXT: (block $label$1 (result (ref i31)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br $label$1 - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -178,7 +178,7 @@ ;; handle that properly (do nothing without hitting an assertion). (br_on_cast $label$1 (ref any) (ref i31) (br_on_cast $label$1 (ref any) (ref i31) - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) ) ) diff --git a/test/lit/passes/remove-unused-brs.wast b/test/lit/passes/remove-unused-brs.wast index e1db006db..82963f792 100644 --- a/test/lit/passes/remove-unused-brs.wast +++ b/test/lit/passes/remove-unused-brs.wast @@ -8,7 +8,7 @@ ;; CHECK: (func $selectify-fresh-lub (type $2) (param $x i32) (result anyref) ;; CHECK-NEXT: (select (result i31ref) ;; CHECK-NEXT: (ref.null none) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $x) @@ -21,7 +21,7 @@ (ref.null none) ) (return - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) ) ) diff --git a/test/lit/passes/signature-pruning.wast b/test/lit/passes/signature-pruning.wast index 3e9d0742f..eaa05ac46 100644 --- a/test/lit/passes/signature-pruning.wast +++ b/test/lit/passes/signature-pruning.wast @@ -797,7 +797,7 @@ ;; CHECK-NEXT: (local.get $anyref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $bar - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -808,7 +808,7 @@ (func $bar (type $sig-bar) (param $anyref anyref) (drop (local.get $anyref)) ;; Mixing a null with something else prevents optimization, of course. - (call $bar (i31.new (i32.const 0))) + (call $bar (ref.i31 (i32.const 0))) (call $bar (ref.null none)) ) ) diff --git a/test/lit/passes/signature-refining.wast b/test/lit/passes/signature-refining.wast index 2ac1aba78..6516b4a24 100644 --- a/test/lit/passes/signature-refining.wast +++ b/test/lit/passes/signature-refining.wast @@ -96,7 +96,7 @@ ;; CHECK-NEXT: (local.get $struct) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call_ref $sig - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (ref.func $func) @@ -109,7 +109,7 @@ (local.get $struct) ) (call_ref $sig - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) (ref.func $func) ) ) diff --git a/test/lit/passes/type-refining.wast b/test/lit/passes/type-refining.wast index 6d0c2257a..e41cd9261 100644 --- a/test/lit/passes/type-refining.wast +++ b/test/lit/passes/type-refining.wast @@ -14,13 +14,13 @@ ;; CHECK: (func $work (type $1) (param $struct (ref $struct)) ;; CHECK-NEXT: (struct.set $struct 1 ;; CHECK-NEXT: (local.get $struct) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (struct.set $struct 2 ;; CHECK-NEXT: (local.get $struct) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -33,11 +33,11 @@ (func $work (param $struct (ref $struct)) (struct.set $struct 1 (local.get $struct) - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) (struct.set $struct 2 (local.get $struct) - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) (drop ;; The type of this struct.get must be updated after the field's type @@ -66,7 +66,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (struct.set $struct 0 ;; CHECK-NEXT: (local.get $struct) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -77,7 +77,7 @@ ) (struct.set $struct 0 (local.get $struct) - (i31.new (i32.const 0)) + (ref.i31 (i32.const 0)) ) ) ) diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast index dc6ebb4c8..3b42db434 100644 --- a/test/lit/wat-kitchen-sink.wast +++ b/test/lit/wat-kitchen-sink.wast @@ -1454,13 +1454,13 @@ ) ;; CHECK: (func $i31-new (type $28) (param $0 i32) (result i31ref) - ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (ref.i31 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $i31-new (param i32) (result i31ref) local.get 0 - i31.new + ref.i31 ) ;; CHECK: (func $i31-get (type $29) (param $0 i31ref) diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast index a693f0098..cc6ebb46e 100644 --- a/test/passes/Oz_fuzz-exec_all-features.wast +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -159,7 +159,7 @@ (func "br-on_non_null" (drop (block $non-null (result (ref any)) - (br_on_non_null $non-null (i31.new (i32.const 0))) + (br_on_non_null $non-null (ref.i31 (i32.const 0))) ;; $x refers to an i31, which is not null, so we will branch, and not ;; log (call $log (i32.const 1)) diff --git a/test/reference-types.wast b/test/reference-types.wast index 64f6e24b7..8706ac0c1 100644 --- a/test/reference-types.wast +++ b/test/reference-types.wast @@ -274,7 +274,7 @@ (drop (if (result anyref) (i32.const 1) - (i31.new + (ref.i31 (i32.const 0) ) (ref.null eq) @@ -356,7 +356,7 @@ (drop (select (result anyref) (local.get $local_eqref) - (i31.new + (ref.i31 (i32.const 0) ) (i32.const 1) diff --git a/test/reference-types.wast.from-wast b/test/reference-types.wast.from-wast index 7b71c554b..6a05ce40c 100644 --- a/test/reference-types.wast.from-wast +++ b/test/reference-types.wast.from-wast @@ -405,7 +405,7 @@ (drop (if (result anyref) (i32.const 1) - (i31.new + (ref.i31 (i32.const 0) ) (ref.null none) @@ -487,7 +487,7 @@ (drop (select (result anyref) (local.get $local_eqref) - (i31.new + (ref.i31 (i32.const 0) ) (i32.const 1) diff --git a/test/reference-types.wast.fromBinary b/test/reference-types.wast.fromBinary index 637a1d2c9..0ce71eb38 100644 --- a/test/reference-types.wast.fromBinary +++ b/test/reference-types.wast.fromBinary @@ -405,7 +405,7 @@ (drop (if (result anyref) (i32.const 1) - (i31.new + (ref.i31 (i32.const 0) ) (ref.null none) @@ -487,7 +487,7 @@ (drop (select (result anyref) (local.get $local_eqref) - (i31.new + (ref.i31 (i32.const 0) ) (i32.const 1) diff --git a/test/reference-types.wast.fromBinary.noDebugInfo b/test/reference-types.wast.fromBinary.noDebugInfo index 8fbc6f614..983dc58fe 100644 --- a/test/reference-types.wast.fromBinary.noDebugInfo +++ b/test/reference-types.wast.fromBinary.noDebugInfo @@ -405,7 +405,7 @@ (drop (if (result anyref) (i32.const 1) - (i31.new + (ref.i31 (i32.const 0) ) (ref.null none) @@ -487,7 +487,7 @@ (drop (select (result anyref) (local.get $0) - (i31.new + (ref.i31 (i32.const 0) ) (i32.const 1) diff --git a/test/spec/i31.wast b/test/spec/i31.wast index e413d3787..6138ca4fa 100644 --- a/test/spec/i31.wast +++ b/test/spec/i31.wast @@ -1,13 +1,13 @@ (module (func (export "new") (param $i i32) (result (ref i31)) - (i31.new (local.get $i)) + (ref.i31 (local.get $i)) ) (func (export "get_u") (param $i i32) (result i32) - (i31.get_u (i31.new (local.get $i))) + (i31.get_u (ref.i31 (local.get $i))) ) (func (export "get_s") (param $i i32) (result i32) - (i31.get_s (i31.new (local.get $i))) + (i31.get_s (ref.i31 (local.get $i))) ) ) diff --git a/test/spec/ref_test.wast b/test/spec/ref_test.wast index 6b6369459..f30e27b6b 100644 --- a/test/spec/ref_test.wast +++ b/test/spec/ref_test.wast @@ -16,10 +16,10 @@ (table.set $ta (i32.const 0) (ref.null any)) (table.set $ta (i32.const 1) (ref.null struct)) (table.set $ta (i32.const 2) (ref.null none)) - (table.set $ta (i32.const 3) (i31.new (i32.const 7))) + (table.set $ta (i32.const 3) (ref.i31 (i32.const 7))) (table.set $ta (i32.const 4) (struct.new_default $st)) (table.set $ta (i32.const 5) (array.new_default $at (i32.const 0))) - (table.set $ta (i32.const 6) (extern.internalize (extern.externalize (i31.new (i32.const 0))))) + (table.set $ta (i32.const 6) (extern.internalize (extern.externalize (ref.i31 (i32.const 0))))) (table.set $ta (i32.const 7) (extern.internalize (ref.null extern))) (table.set $tf (i32.const 0) (ref.null nofunc)) @@ -28,8 +28,8 @@ (table.set $te (i32.const 0) (ref.null noextern)) (table.set $te (i32.const 1) (ref.null extern)) - (table.set $te (i32.const 2) (extern.externalize (i31.new (i32.const 0)))) - (table.set $te (i32.const 3) (extern.externalize (i31.new (i32.const 8)))) + (table.set $te (i32.const 2) (extern.externalize (ref.i31 (i32.const 0)))) + (table.set $te (i32.const 3) (extern.externalize (ref.i31 (i32.const 8)))) (table.set $te (i32.const 4) (extern.externalize (struct.new_default $st))) (table.set $te (i32.const 5) (extern.externalize (ref.null any))) ) |