diff options
author | Thomas Lively <tlively@google.com> | 2023-01-09 16:23:57 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 14:23:57 -0800 |
commit | 67abc2a1b9adcdf080387a29e0c92b6f5a31057a (patch) | |
tree | d8e8304e9ecdd700b56b949bb5132b26e09362f4 /test/binaryen.js | |
parent | e3d9b82d9f8910063373e2952582de545659d448 (diff) | |
download | binaryen-67abc2a1b9adcdf080387a29e0c92b6f5a31057a.tar.gz binaryen-67abc2a1b9adcdf080387a29e0c92b6f5a31057a.tar.bz2 binaryen-67abc2a1b9adcdf080387a29e0c92b6f5a31057a.zip |
Replace `RefIs` with `RefIsNull` (#5401)
* Replace `RefIs` with `RefIsNull`
The other `ref.is*` instructions are deprecated and expressible in terms of
`ref.test`. Update binary and text parsing to parse those instructions as
`RefTest` expressions. Also update the printing and emitting of `RefTest`
expressions to emit the legacy instructions for now to minimize test changes and
make this a mostly non-functional change. Since `ref.is_null` is the only
`RefIs` instruction left, remove the `RefIsOp` field and rename the expression
class to `RefIsNull`.
The few test changes are due to the fact that `ref.is*` instructions are now
subject to `ref.test` validation, and in particular it is no longer valid to
perform a `ref.is_func` on a value outside of the `func` type hierarchy.
Diffstat (limited to 'test/binaryen.js')
-rw-r--r-- | test/binaryen.js/expressions.js | 53 | ||||
-rw-r--r-- | test/binaryen.js/expressions.js.txt | 2 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js | 2 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 2 |
4 files changed, 19 insertions, 40 deletions
diff --git a/test/binaryen.js/expressions.js b/test/binaryen.js/expressions.js index c0bc402a0..ee55ee90b 100644 --- a/test/binaryen.js/expressions.js +++ b/test/binaryen.js/expressions.js @@ -1417,51 +1417,30 @@ console.log("# MemoryFill"); module.dispose(); })(); -console.log("# RefIs"); -(function testRefIs() { +console.log("# RefIsNull"); +(function testRefIsNull() { const module = new binaryen.Module(); - var op = binaryen.Operations.RefIsNull; var value = module.local.get(1, binaryen.externref); - const theRefIs = binaryen.RefIs(module.ref.is_null(value)); - assert(theRefIs instanceof binaryen.RefIs); - assert(theRefIs instanceof binaryen.Expression); - assert(theRefIs.op === op); - assert(theRefIs.value === value); - assert(theRefIs.type === binaryen.i32); - - theRefIs.op = op = binaryen.Operations.RefIsFunc; - assert(theRefIs.op === op); - theRefIs.op = op = binaryen.Operations.RefIsNull; - theRefIs.value = value = module.local.get(2, binaryen.externref); - assert(theRefIs.value === value); - theRefIs.type = binaryen.f64; - theRefIs.finalize(); - assert(theRefIs.type === binaryen.i32); - - console.log(theRefIs.toText()); + const theRefIsNull = binaryen.RefIsNull(module.ref.is_null(value)); + assert(theRefIsNull instanceof binaryen.RefIsNull); + assert(theRefIsNull instanceof binaryen.Expression); + assert(theRefIsNull.value === value); + assert(theRefIsNull.type === binaryen.i32); + + theRefIsNull.value = value = module.local.get(2, binaryen.externref); + assert(theRefIsNull.value === value); + theRefIsNull.type = binaryen.f64; + theRefIsNull.finalize(); + assert(theRefIsNull.type === binaryen.i32); + + console.log(theRefIsNull.toText()); assert( - theRefIs.toText() + theRefIsNull.toText() == "(ref.is_null\n (local.get $2)\n)\n" ); - assert( - binaryen.RefIs(module.ref.is_func(value)).toText() - == - "(ref.is_func\n (local.get $2)\n)\n" - ); - assert( - binaryen.RefIs(module.ref.is_data(value)).toText() - == - "(ref.is_data\n (local.get $2)\n)\n" - ); - assert( - binaryen.RefIs(module.ref.is_i31(value)).toText() - == - "(ref.is_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 fbf69888a..75f3a8d54 100644 --- a/test/binaryen.js/expressions.js.txt +++ b/test/binaryen.js/expressions.js.txt @@ -214,7 +214,7 @@ (i32.const 6) ) -# RefIs +# RefIsNull (ref.is_null (local.get $2) ) diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 52d8fd16f..0de23883a 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -145,7 +145,7 @@ function test_ids() { console.log("MemoryFillId: " + binaryen.MemoryFillId); console.log("PopId: " + binaryen.PopId); console.log("RefNullId: " + binaryen.RefNullId); - console.log("RefIsId: " + binaryen.RefIsId); + console.log("RefIsNullId: " + binaryen.RefIsNullId); console.log("RefFuncId: " + binaryen.RefFuncId); console.log("RefEqId: " + binaryen.RefEqId); console.log("TableGetId: " + binaryen.TableGetId); diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index c59c2dac1..4798c8592 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -75,7 +75,7 @@ MemoryCopyId: 38 MemoryFillId: 39 PopId: 40 RefNullId: 41 -RefIsId: 42 +RefIsNullId: 42 RefFuncId: 43 RefEqId: 44 TableGetId: 45 |