| 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" |
| 11 #include "src/wasm/wasm-limits.h" |
| 11 #include "src/wasm/wasm-module.h" | 12 #include "src/wasm/wasm-module.h" |
| 12 | 13 |
| 13 #include "src/zone/accounting-allocator.h" | 14 #include "src/zone/accounting-allocator.h" |
| 14 #include "src/zone/zone-containers.h" | 15 #include "src/zone/zone-containers.h" |
| 15 | 16 |
| 16 namespace v8 { | 17 namespace v8 { |
| 17 namespace internal { | 18 namespace internal { |
| 18 namespace wasm { | 19 namespace wasm { |
| 19 | 20 |
| 20 #if DEBUG | 21 #if DEBUG |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 } | 657 } |
| 657 | 658 |
| 658 static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) { | 659 static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) { |
| 659 return bit_cast<int64_t>(a); | 660 return bit_cast<int64_t>(a); |
| 660 } | 661 } |
| 661 | 662 |
| 662 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages, | 663 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages, |
| 663 WasmInstance* instance) { | 664 WasmInstance* instance) { |
| 664 // TODO(ahaas): Move memory allocation to wasm-module.cc for better | 665 // TODO(ahaas): Move memory allocation to wasm-module.cc for better |
| 665 // encapsulation. | 666 // encapsulation. |
| 666 if (delta_pages > wasm::WasmModule::kV8MaxPages) { | 667 if (delta_pages > wasm::kV8MaxWasmMemoryPages) { |
| 667 return -1; | 668 return -1; |
| 668 } | 669 } |
| 669 uint32_t old_size = instance->mem_size; | 670 uint32_t old_size = instance->mem_size; |
| 670 uint32_t new_size; | 671 uint32_t new_size; |
| 671 byte* new_mem_start; | 672 byte* new_mem_start; |
| 672 if (instance->mem_size == 0) { | 673 if (instance->mem_size == 0) { |
| 673 // TODO(gdeepti): Fix bounds check to take into account size of memtype. | 674 // TODO(gdeepti): Fix bounds check to take into account size of memtype. |
| 674 new_size = delta_pages * wasm::WasmModule::kPageSize; | 675 new_size = delta_pages * wasm::WasmModule::kPageSize; |
| 675 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte))); | 676 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte))); |
| 676 if (!new_mem_start) { | 677 if (!new_mem_start) { |
| 677 return -1; | 678 return -1; |
| 678 } | 679 } |
| 679 } else { | 680 } else { |
| 680 DCHECK_NOT_NULL(instance->mem_start); | 681 DCHECK_NOT_NULL(instance->mem_start); |
| 681 new_size = old_size + delta_pages * wasm::WasmModule::kPageSize; | 682 new_size = old_size + delta_pages * wasm::WasmModule::kPageSize; |
| 682 if (new_size > | 683 if (new_size > wasm::kV8MaxWasmMemoryPages * wasm::WasmModule::kPageSize) { |
| 683 wasm::WasmModule::kV8MaxPages * wasm::WasmModule::kPageSize) { | |
| 684 return -1; | 684 return -1; |
| 685 } | 685 } |
| 686 new_mem_start = static_cast<byte*>(realloc(instance->mem_start, new_size)); | 686 new_mem_start = static_cast<byte*>(realloc(instance->mem_start, new_size)); |
| 687 if (!new_mem_start) { | 687 if (!new_mem_start) { |
| 688 return -1; | 688 return -1; |
| 689 } | 689 } |
| 690 // Zero initializing uninitialized memory from realloc | 690 // Zero initializing uninitialized memory from realloc |
| 691 memset(new_mem_start + old_size, 0, new_size - old_size); | 691 memset(new_mem_start + old_size, 0, new_size - old_size); |
| 692 } | 692 } |
| 693 instance->mem_start = new_mem_start; | 693 instance->mem_start = new_mem_start; |
| (...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 | 1888 |
| 1889 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( | 1889 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( |
| 1890 Zone* zone, const byte* start, const byte* end) { | 1890 Zone* zone, const byte* start, const byte* end) { |
| 1891 ControlTransfers targets(zone, nullptr, start, end); | 1891 ControlTransfers targets(zone, nullptr, start, end); |
| 1892 return targets.map_; | 1892 return targets.map_; |
| 1893 } | 1893 } |
| 1894 | 1894 |
| 1895 } // namespace wasm | 1895 } // namespace wasm |
| 1896 } // namespace internal | 1896 } // namespace internal |
| 1897 } // namespace v8 | 1897 } // namespace v8 |
| OLD | NEW |