| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // Check the thread finished with the right value. | 290 // Check the thread finished with the right value. |
| 291 CHECK_EQ(WasmInterpreter::FINISHED, thread->state()); | 291 CHECK_EQ(WasmInterpreter::FINISHED, thread->state()); |
| 292 uint32_t expected = (*a) & (b); | 292 uint32_t expected = (*a) & (b); |
| 293 CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>()); | 293 CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>()); |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 TEST(GrowMemory) { | 299 TEST(GrowMemory) { |
| 300 WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); | 300 { |
| 301 r.module().AddMemory(WasmModule::kPageSize); | 301 WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); |
| 302 BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); | 302 r.module().AddMemory(WasmModule::kPageSize); |
| 303 CHECK_EQ(1, r.Call(1)); | 303 r.module().SetMaxMemPages(10); |
| 304 BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); |
| 305 CHECK_EQ(1, r.Call(1)); |
| 306 } |
| 307 { |
| 308 WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); |
| 309 r.module().AddMemory(WasmModule::kPageSize); |
| 310 r.module().SetMaxMemPages(10); |
| 311 BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); |
| 312 CHECK_EQ(-1, r.Call(11)); |
| 313 } |
| 304 } | 314 } |
| 305 | 315 |
| 306 TEST(GrowMemoryPreservesData) { | 316 TEST(GrowMemoryPreservesData) { |
| 307 int32_t index = 16; | 317 int32_t index = 16; |
| 308 int32_t value = 2335; | 318 int32_t value = 2335; |
| 309 WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); | 319 WasmRunner<int32_t, uint32_t> r(kExecuteInterpreted); |
| 310 r.module().AddMemory(WasmModule::kPageSize); | 320 r.module().AddMemory(WasmModule::kPageSize); |
| 311 BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index), | 321 BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index), |
| 312 WASM_I32V(value)), | 322 WASM_I32V(value)), |
| 313 WASM_GROW_MEMORY(WASM_GET_LOCAL(0)), WASM_DROP, | 323 WASM_GROW_MEMORY(WASM_GET_LOCAL(0)), WASM_DROP, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 BUILD(r, WASM_F64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 393 BUILD(r, WASM_F64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 384 r.Call(1048575.5, 2.5); | 394 r.Call(1048575.5, 2.5); |
| 385 CHECK(!r.possible_nondeterminism()); | 395 CHECK(!r.possible_nondeterminism()); |
| 386 r.Call(std::numeric_limits<double>::infinity(), 0.0); | 396 r.Call(std::numeric_limits<double>::infinity(), 0.0); |
| 387 CHECK(r.possible_nondeterminism()); | 397 CHECK(r.possible_nondeterminism()); |
| 388 } | 398 } |
| 389 } | 399 } |
| 390 } // namespace wasm | 400 } // namespace wasm |
| 391 } // namespace internal | 401 } // namespace internal |
| 392 } // namespace v8 | 402 } // namespace v8 |
| OLD | NEW |