From 67abc2a1b9adcdf080387a29e0c92b6f5a31057a Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Mon, 9 Jan 2023 16:23:57 -0600 Subject: 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. --- src/wasm-interpreter.h | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/wasm-interpreter.h') diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 181114c92..104f06585 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -1336,26 +1336,15 @@ public: NOTE_ENTER("RefNull"); return Literal::makeNull(curr->type.getHeapType()); } - Flow visitRefIs(RefIs* curr) { - NOTE_ENTER("RefIs"); + Flow visitRefIsNull(RefIsNull* curr) { + NOTE_ENTER("RefIsNull"); Flow flow = visit(curr->value); if (flow.breaking()) { return flow; } const auto& value = flow.getSingleValue(); NOTE_EVAL1(value); - switch (curr->op) { - case RefIsNull: - return Literal(value.isNull()); - case RefIsFunc: - return Literal(value.type.isFunction()); - case RefIsData: - return Literal(value.isData()); - case RefIsI31: - return Literal(value.type.getHeapType() == HeapType::i31); - default: - WASM_UNREACHABLE("unimplemented ref.is_*"); - } + return Literal(int32_t(value.isNull())); } Flow visitRefFunc(RefFunc* curr) { NOTE_ENTER("RefFunc"); -- cgit v1.2.3