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

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

Issue 2671803002: [wasm] Refactor the non-determinism detection in the interpreter. (Closed)
Patch Set: Created 3 years, 11 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
« src/wasm/wasm-interpreter.cc ('K') | « src/wasm/wasm-interpreter.cc ('k') | no next file » | 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 71744ae69d87044a49c3487af92011f01b88c576..21de034f43690d02160477fd5c1b46424484bf7f 100644
--- a/test/cctest/wasm/test-run-wasm-interpreter.cc
+++ b/test/cctest/wasm/test-run-wasm-interpreter.cc
@@ -343,57 +343,43 @@ TEST(GrowMemoryInvalidSize) {
TEST(TestPossibleNondeterminism) {
{
- // F32Div may produced NaN
- WasmRunner<float, float, float> r(kExecuteInterpreted);
- BUILD(r, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
- r.Call(1048575.5f, 2.5f);
+ WasmRunner<int32_t, float> r(kExecuteInterpreted);
+ BUILD(r, WASM_I32_REINTERPRET_F32(WASM_GET_LOCAL(0)));
Eric Holk 2017/02/03 03:11:26 Can't we still have nondeterminism if the function
ahaas 2017/02/03 09:16:06 Non-determinism by itself does not hurt us as long
+ r.Call(1048575.5f);
CHECK(!r.possible_nondeterminism());
- r.Call(0.0f, 0.0f);
+ r.Call(std::numeric_limits<float>::quiet_NaN());
CHECK(r.possible_nondeterminism());
}
{
- // F32Sqrt may produced NaN
- WasmRunner<float, float> r(kExecuteInterpreted);
- BUILD(r, WASM_F32_SQRT(WASM_GET_LOCAL(0)));
- r.Call(16.0f);
+ WasmRunner<int64_t, double> r(kExecuteInterpreted);
+ BUILD(r, WASM_I64_REINTERPRET_F64(WASM_GET_LOCAL(0)));
+ r.Call(16.0);
CHECK(!r.possible_nondeterminism());
- r.Call(-1048575.5f);
+ r.Call(std::numeric_limits<double>::quiet_NaN());
CHECK(r.possible_nondeterminism());
}
{
- // F32Mul may produced NaN
- WasmRunner<float, float, float> r(kExecuteInterpreted);
- 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
- WasmRunner<double, double, double> r(kExecuteInterpreted);
- 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
- WasmRunner<double, double> r(kExecuteInterpreted);
- BUILD(r, WASM_F64_SQRT(WASM_GET_LOCAL(0)));
Eric Holk 2017/02/03 03:11:26 Wouldn't there still be some value in testing sqrt
ahaas 2017/02/03 09:16:06 The possible_nondeterminism flag causes us to not
titzer 2017/02/03 09:48:05 I think Andreas is saying that we do actually test
- r.Call(1048575.5);
+ int32_t index = 16;
+ WasmRunner<int32_t, float> r(kExecuteInterpreted);
+ r.module().AddMemory(WasmModule::kPageSize);
+ BUILD(r, WASM_STORE_MEM(MachineType::Float32(), WASM_I32V(index),
+ WASM_GET_LOCAL(0)),
+ WASM_I32V(index));
+ r.Call(1345.3456f);
CHECK(!r.possible_nondeterminism());
- r.Call(-1048575.5);
+ r.Call(std::numeric_limits<float>::quiet_NaN());
CHECK(r.possible_nondeterminism());
}
{
- // F64Mul may produced NaN
- WasmRunner<double, double, double> r(kExecuteInterpreted);
- BUILD(r, WASM_F64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
- r.Call(1048575.5, 2.5);
+ int32_t index = 16;
+ WasmRunner<int32_t, double> r(kExecuteInterpreted);
+ r.module().AddMemory(WasmModule::kPageSize);
+ BUILD(r, WASM_STORE_MEM(MachineType::Float64(), WASM_I32V(index),
+ WASM_GET_LOCAL(0)),
+ WASM_I32V(index));
+ r.Call(1345.3456);
CHECK(!r.possible_nondeterminism());
- r.Call(std::numeric_limits<double>::infinity(), 0.0);
+ r.Call(std::numeric_limits<double>::quiet_NaN());
CHECK(r.possible_nondeterminism());
}
}
« src/wasm/wasm-interpreter.cc ('K') | « src/wasm/wasm-interpreter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698