OLD | NEW |
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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 { | 326 { |
327 // Grow memory by an invalid amount without initial memory. | 327 // Grow memory by an invalid amount without initial memory. |
328 TestingModule module(kExecuteInterpreted); | 328 TestingModule module(kExecuteInterpreted); |
329 WasmRunner<int32_t> r(&module, MachineType::Uint32()); | 329 WasmRunner<int32_t> r(&module, MachineType::Uint32()); |
330 module.AddMemory(WasmModule::kPageSize); | 330 module.AddMemory(WasmModule::kPageSize); |
331 BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); | 331 BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); |
332 CHECK_EQ(-1, r.Call(1048575)); | 332 CHECK_EQ(-1, r.Call(1048575)); |
333 } | 333 } |
334 } | 334 } |
335 | 335 |
| 336 TEST(TestMayProduceNaN) { |
| 337 { |
| 338 // F32Div may produced NaN |
| 339 TestingModule module(kExecuteInterpreted); |
| 340 WasmRunner<float> r(&module, MachineType::Float32(), |
| 341 MachineType::Float32()); |
| 342 BUILD(r, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 343 r.Call(1048575.5f, 2.5f); |
| 344 CHECK(r.may_produced_nan()); |
| 345 } |
| 346 { |
| 347 // F32Sqrt may produced NaN |
| 348 TestingModule module(kExecuteInterpreted); |
| 349 WasmRunner<float> r(&module, MachineType::Float32()); |
| 350 BUILD(r, WASM_F32_SQRT(WASM_GET_LOCAL(0))); |
| 351 r.Call(1048575.5f); |
| 352 CHECK(r.may_produced_nan()); |
| 353 } |
| 354 { |
| 355 // F64Div may produced NaN |
| 356 TestingModule module(kExecuteInterpreted); |
| 357 WasmRunner<double> r(&module, MachineType::Float64(), |
| 358 MachineType::Float64()); |
| 359 BUILD(r, WASM_F64_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 360 r.Call(1048575.5, 2.5); |
| 361 CHECK(r.may_produced_nan()); |
| 362 } |
| 363 { |
| 364 // F64Sqrt may produced NaN |
| 365 TestingModule module(kExecuteInterpreted); |
| 366 WasmRunner<double> r(&module, MachineType::Float64()); |
| 367 BUILD(r, WASM_F64_SQRT(WASM_GET_LOCAL(0))); |
| 368 r.Call(1048575.5); |
| 369 CHECK(r.may_produced_nan()); |
| 370 } |
| 371 { |
| 372 // Sanity check: F64Mul cannot produce a NaN without NaN input. |
| 373 TestingModule module(kExecuteInterpreted); |
| 374 WasmRunner<double> r(&module, MachineType::Float64(), |
| 375 MachineType::Float64()); |
| 376 BUILD(r, WASM_F64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 377 r.Call(1048575.5, 2.5); |
| 378 CHECK(!r.may_produced_nan()); |
| 379 } |
| 380 } |
336 } // namespace wasm | 381 } // namespace wasm |
337 } // namespace internal | 382 } // namespace internal |
338 } // namespace v8 | 383 } // namespace v8 |
OLD | NEW |