Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: test/cctest/wasm/test-run-wasm-interpreter.cc

Issue 2438603003: [wasm] Track in the interpreter if a NaN could have been produced. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698