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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 int32_t value = 2335; | 299 int32_t value = 2335; |
300 TestingModule module(kExecuteInterpreted); | 300 TestingModule module(kExecuteInterpreted); |
301 WasmRunner<int32_t> r(&module, MachineType::Uint32()); | 301 WasmRunner<int32_t> r(&module, MachineType::Uint32()); |
302 module.AddMemory(WasmModule::kPageSize); | 302 module.AddMemory(WasmModule::kPageSize); |
303 BUILD(r, WASM_BLOCK(WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index), | 303 BUILD(r, WASM_BLOCK(WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index), |
304 WASM_I32V(value)), | 304 WASM_I32V(value)), |
305 WASM_GROW_MEMORY(WASM_GET_LOCAL(0)), | 305 WASM_GROW_MEMORY(WASM_GET_LOCAL(0)), |
306 WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index)))); | 306 WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index)))); |
307 CHECK_EQ(value, r.Call(1)); | 307 CHECK_EQ(value, r.Call(1)); |
308 } | 308 } |
| 309 |
| 310 TEST(GrowMemoryInvalidSize) { |
| 311 { |
| 312 // Grow memory by an invalid amount without initial memory. |
| 313 TestingModule module(kExecuteInterpreted); |
| 314 WasmRunner<int32_t> r(&module, MachineType::Uint32()); |
| 315 BUILD(r, WASM_BLOCK(WASM_GROW_MEMORY(WASM_GET_LOCAL(0)))); |
| 316 CHECK_EQ(-1, r.Call(1048575)); |
| 317 } |
| 318 { |
| 319 // Grow memory by an invalid amount without initial memory. |
| 320 TestingModule module(kExecuteInterpreted); |
| 321 WasmRunner<int32_t> r(&module, MachineType::Uint32()); |
| 322 module.AddMemory(WasmModule::kPageSize); |
| 323 BUILD(r, WASM_BLOCK(WASM_GROW_MEMORY(WASM_GET_LOCAL(0)))); |
| 324 CHECK_EQ(-1, r.Call(1048575)); |
| 325 } |
| 326 } |
| 327 |
309 } // namespace wasm | 328 } // namespace wasm |
310 } // namespace internal | 329 } // namespace internal |
311 } // namespace v8 | 330 } // namespace v8 |
OLD | NEW |