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 "src/wasm/wasm-interpreter.h" | 5 #include "src/wasm/wasm-interpreter.h" |
6 | 6 |
7 #include "src/utils.h" | 7 #include "src/utils.h" |
8 #include "src/wasm/ast-decoder.h" | 8 #include "src/wasm/ast-decoder.h" |
9 #include "src/wasm/decoder.h" | 9 #include "src/wasm/decoder.h" |
10 #include "src/wasm/wasm-external-refs.h" | 10 #include "src/wasm/wasm-external-refs.h" |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 } | 651 } |
652 | 652 |
653 static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) { | 653 static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) { |
654 return bit_cast<int64_t>(a); | 654 return bit_cast<int64_t>(a); |
655 } | 655 } |
656 | 656 |
657 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages, | 657 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages, |
658 WasmModuleInstance* instance) { | 658 WasmModuleInstance* instance) { |
659 // TODO(ahaas): Move memory allocation to wasm-module.cc for better | 659 // TODO(ahaas): Move memory allocation to wasm-module.cc for better |
660 // encapsulation. | 660 // encapsulation. |
| 661 if (delta_pages > wasm::WasmModule::kMaxMemPages) { |
| 662 return -1; |
| 663 } |
661 uint32_t old_size = instance->mem_size; | 664 uint32_t old_size = instance->mem_size; |
662 uint32_t new_size; | 665 uint32_t new_size; |
663 byte* new_mem_start; | 666 byte* new_mem_start; |
664 if (instance->mem_size == 0) { | 667 if (instance->mem_size == 0) { |
665 if (delta_pages > wasm::WasmModule::kMaxMemPages) { | 668 if (delta_pages > wasm::WasmModule::kMaxMemPages) { |
666 return -1; | 669 return -1; |
667 } | 670 } |
668 // TODO(gdeepti): Fix bounds check to take into account size of memtype. | 671 // TODO(gdeepti): Fix bounds check to take into account size of memtype. |
669 new_size = delta_pages * wasm::WasmModule::kPageSize; | 672 new_size = delta_pages * wasm::WasmModule::kPageSize; |
670 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte))); | 673 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte))); |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 | 1850 |
1848 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( | 1851 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( |
1849 Zone* zone, const byte* start, const byte* end) { | 1852 Zone* zone, const byte* start, const byte* end) { |
1850 ControlTransfers targets(zone, 0, start, end); | 1853 ControlTransfers targets(zone, 0, start, end); |
1851 return targets.map_; | 1854 return targets.map_; |
1852 } | 1855 } |
1853 | 1856 |
1854 } // namespace wasm | 1857 } // namespace wasm |
1855 } // namespace internal | 1858 } // namespace internal |
1856 } // namespace v8 | 1859 } // namespace v8 |
OLD | NEW |