| Index: test/cctest/wasm/test-run-wasm-interpreter.cc
|
| diff --git a/test/cctest/wasm/test-run-wasm-interpreter.cc b/test/cctest/wasm/test-run-wasm-interpreter.cc
|
| index 0489d016d7ba4ef52fe67283fdcfcacebb5293f1..5a151c1203f61a5e53632acffcc3fc243d5ace7c 100644
|
| --- a/test/cctest/wasm/test-run-wasm-interpreter.cc
|
| +++ b/test/cctest/wasm/test-run-wasm-interpreter.cc
|
| @@ -333,6 +333,51 @@ TEST(GrowMemoryInvalidSize) {
|
| }
|
| }
|
|
|
| +TEST(TestMayProduceNaN) {
|
| + {
|
| + // F32Div may produced NaN
|
| + TestingModule module(kExecuteInterpreted);
|
| + WasmRunner<float> r(&module, MachineType::Float32(),
|
| + MachineType::Float32());
|
| + BUILD(r, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
|
| + r.Call(1048575.5f, 2.5f);
|
| + CHECK(r.may_produced_nan());
|
| + }
|
| + {
|
| + // F32Sqrt may produced NaN
|
| + TestingModule module(kExecuteInterpreted);
|
| + WasmRunner<float> r(&module, MachineType::Float32());
|
| + BUILD(r, WASM_F32_SQRT(WASM_GET_LOCAL(0)));
|
| + r.Call(1048575.5f);
|
| + CHECK(r.may_produced_nan());
|
| + }
|
| + {
|
| + // F64Div may produced NaN
|
| + TestingModule module(kExecuteInterpreted);
|
| + WasmRunner<double> r(&module, MachineType::Float64(),
|
| + MachineType::Float64());
|
| + BUILD(r, WASM_F64_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
|
| + r.Call(1048575.5, 2.5);
|
| + CHECK(r.may_produced_nan());
|
| + }
|
| + {
|
| + // F64Sqrt may produced NaN
|
| + TestingModule module(kExecuteInterpreted);
|
| + WasmRunner<double> r(&module, MachineType::Float64());
|
| + BUILD(r, WASM_F64_SQRT(WASM_GET_LOCAL(0)));
|
| + r.Call(1048575.5);
|
| + CHECK(r.may_produced_nan());
|
| + }
|
| + {
|
| + // Sanity check: F64Mul cannot produce a NaN without NaN input.
|
| + TestingModule module(kExecuteInterpreted);
|
| + WasmRunner<double> r(&module, MachineType::Float64(),
|
| + MachineType::Float64());
|
| + BUILD(r, WASM_F64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
|
| + r.Call(1048575.5, 2.5);
|
| + CHECK(!r.may_produced_nan());
|
| + }
|
| +}
|
| } // namespace wasm
|
| } // namespace internal
|
| } // namespace v8
|
|
|