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

Side by Side 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, 10 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 unified diff | Download patch
« src/wasm/wasm-interpreter.cc ('K') | « src/wasm/wasm-interpreter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // Grow memory by an invalid amount without initial memory. 336 // Grow memory by an invalid amount without initial memory.
337 WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); 337 WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted);
338 r.module().AddMemory(WasmModule::kPageSize); 338 r.module().AddMemory(WasmModule::kPageSize);
339 BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); 339 BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0)));
340 CHECK_EQ(-1, r.Call(1048575)); 340 CHECK_EQ(-1, r.Call(1048575));
341 } 341 }
342 } 342 }
343 343
344 TEST(TestPossibleNondeterminism) { 344 TEST(TestPossibleNondeterminism) {
345 { 345 {
346 // F32Div may produced NaN 346 WasmRunner<int32_t, float> r(kExecuteInterpreted);
347 WasmRunner<float, float, float> r(kExecuteInterpreted); 347 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
348 BUILD(r, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 348 r.Call(1048575.5f);
349 r.Call(1048575.5f, 2.5f);
350 CHECK(!r.possible_nondeterminism()); 349 CHECK(!r.possible_nondeterminism());
351 r.Call(0.0f, 0.0f); 350 r.Call(std::numeric_limits<float>::quiet_NaN());
352 CHECK(r.possible_nondeterminism()); 351 CHECK(r.possible_nondeterminism());
353 } 352 }
354 { 353 {
355 // F32Sqrt may produced NaN 354 WasmRunner<int64_t, double> r(kExecuteInterpreted);
356 WasmRunner<float, float> r(kExecuteInterpreted); 355 BUILD(r, WASM_I64_REINTERPRET_F64(WASM_GET_LOCAL(0)));
357 BUILD(r, WASM_F32_SQRT(WASM_GET_LOCAL(0))); 356 r.Call(16.0);
358 r.Call(16.0f);
359 CHECK(!r.possible_nondeterminism()); 357 CHECK(!r.possible_nondeterminism());
360 r.Call(-1048575.5f); 358 r.Call(std::numeric_limits<double>::quiet_NaN());
361 CHECK(r.possible_nondeterminism()); 359 CHECK(r.possible_nondeterminism());
362 } 360 }
363 { 361 {
364 // F32Mul may produced NaN 362 int32_t index = 16;
365 WasmRunner<float, float, float> r(kExecuteInterpreted); 363 WasmRunner<int32_t, float> r(kExecuteInterpreted);
366 BUILD(r, WASM_F32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 364 r.module().AddMemory(WasmModule::kPageSize);
367 r.Call(1048575.5f, 2.5f); 365 BUILD(r, WASM_STORE_MEM(MachineType::Float32(), WASM_I32V(index),
366 WASM_GET_LOCAL(0)),
367 WASM_I32V(index));
368 r.Call(1345.3456f);
368 CHECK(!r.possible_nondeterminism()); 369 CHECK(!r.possible_nondeterminism());
369 r.Call(std::numeric_limits<float>::infinity(), 0.0f); 370 r.Call(std::numeric_limits<float>::quiet_NaN());
370 CHECK(r.possible_nondeterminism()); 371 CHECK(r.possible_nondeterminism());
371 } 372 }
372 { 373 {
373 // F64Div may produced NaN 374 int32_t index = 16;
374 WasmRunner<double, double, double> r(kExecuteInterpreted); 375 WasmRunner<int32_t, double> r(kExecuteInterpreted);
375 BUILD(r, WASM_F64_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 376 r.module().AddMemory(WasmModule::kPageSize);
376 r.Call(1048575.5, 2.5); 377 BUILD(r, WASM_STORE_MEM(MachineType::Float64(), WASM_I32V(index),
378 WASM_GET_LOCAL(0)),
379 WASM_I32V(index));
380 r.Call(1345.3456);
377 CHECK(!r.possible_nondeterminism()); 381 CHECK(!r.possible_nondeterminism());
378 r.Call(0.0, 0.0); 382 r.Call(std::numeric_limits<double>::quiet_NaN());
379 CHECK(r.possible_nondeterminism());
380 }
381 {
382 // F64Sqrt may produced NaN
383 WasmRunner<double, double> r(kExecuteInterpreted);
384 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
385 r.Call(1048575.5);
386 CHECK(!r.possible_nondeterminism());
387 r.Call(-1048575.5);
388 CHECK(r.possible_nondeterminism());
389 }
390 {
391 // F64Mul may produced NaN
392 WasmRunner<double, double, double> r(kExecuteInterpreted);
393 BUILD(r, WASM_F64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
394 r.Call(1048575.5, 2.5);
395 CHECK(!r.possible_nondeterminism());
396 r.Call(std::numeric_limits<double>::infinity(), 0.0);
397 CHECK(r.possible_nondeterminism()); 383 CHECK(r.possible_nondeterminism());
398 } 384 }
399 } 385 }
400 } // namespace wasm 386 } // namespace wasm
401 } // namespace internal 387 } // namespace internal
402 } // namespace v8 388 } // namespace v8
OLDNEW
« 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