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

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: Fixed nits. 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
« no previous file with comments | « src/wasm/wasm-interpreter.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e716b29f7d66a180579b6a980544661e448c2c25 100644
--- a/test/cctest/wasm/test-run-wasm-interpreter.cc
+++ b/test/cctest/wasm/test-run-wasm-interpreter.cc
@@ -333,6 +333,72 @@ TEST(GrowMemoryInvalidSize) {
}
}
+TEST(TestPossibleNondeterminism) {
+ {
+ // 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.possible_nondeterminism());
+ r.Call(0.0f, 0.0f);
+ CHECK(r.possible_nondeterminism());
+ }
+ {
+ // F32Sqrt may produced NaN
+ TestingModule module(kExecuteInterpreted);
+ WasmRunner<float> r(&module, MachineType::Float32());
+ BUILD(r, WASM_F32_SQRT(WASM_GET_LOCAL(0)));
+ r.Call(16.0f);
+ CHECK(!r.possible_nondeterminism());
+ r.Call(-1048575.5f);
+ CHECK(r.possible_nondeterminism());
+ }
+ {
+ // F32Mul may produced NaN
+ TestingModule module(kExecuteInterpreted);
+ WasmRunner<float> r(&module, MachineType::Float32(),
+ MachineType::Float32());
+ BUILD(r, WASM_F32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
+ r.Call(1048575.5f, 2.5f);
+ CHECK(!r.possible_nondeterminism());
+ r.Call(std::numeric_limits<float>::infinity(), 0.0f);
+ CHECK(r.possible_nondeterminism());
+ }
+ {
+ // 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.possible_nondeterminism());
+ r.Call(0.0, 0.0);
+ CHECK(r.possible_nondeterminism());
+ }
+ {
+ // 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.possible_nondeterminism());
+ r.Call(-1048575.5);
+ CHECK(r.possible_nondeterminism());
+ }
+ {
+ // F64Mul may produced NaN
+ 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.possible_nondeterminism());
+ r.Call(std::numeric_limits<double>::infinity(), 0.0);
+ CHECK(r.possible_nondeterminism());
+ }
+}
} // namespace wasm
} // namespace internal
} // namespace v8
« no previous file with comments | « src/wasm/wasm-interpreter.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698