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/decoder.h" | 8 #include "src/wasm/decoder.h" |
9 #include "src/wasm/function-body-decoder.h" | 9 #include "src/wasm/function-body-decoder.h" |
10 #include "src/wasm/wasm-external-refs.h" | 10 #include "src/wasm/wasm-external-refs.h" |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 609 } |
610 | 610 |
611 static inline int64_t ExecuteI64ReinterpretF64(WasmVal a) { | 611 static inline int64_t ExecuteI64ReinterpretF64(WasmVal a) { |
612 return a.to_unchecked<int64_t>(); | 612 return a.to_unchecked<int64_t>(); |
613 } | 613 } |
614 | 614 |
615 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages, | 615 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages, |
616 WasmInstance* instance) { | 616 WasmInstance* instance) { |
617 // TODO(ahaas): Move memory allocation to wasm-module.cc for better | 617 // TODO(ahaas): Move memory allocation to wasm-module.cc for better |
618 // encapsulation. | 618 // encapsulation. |
619 if (delta_pages > wasm::kV8MaxWasmMemoryPages || | 619 if (delta_pages > FLAG_wasm_max_mem_pages || |
620 delta_pages > instance->module->max_mem_pages) { | 620 delta_pages > instance->module->max_mem_pages) { |
621 return -1; | 621 return -1; |
622 } | 622 } |
623 uint32_t old_size = instance->mem_size; | 623 uint32_t old_size = instance->mem_size; |
624 uint32_t new_size; | 624 uint32_t new_size; |
625 byte* new_mem_start; | 625 byte* new_mem_start; |
626 if (instance->mem_size == 0) { | 626 if (instance->mem_size == 0) { |
627 // TODO(gdeepti): Fix bounds check to take into account size of memtype. | 627 // TODO(gdeepti): Fix bounds check to take into account size of memtype. |
628 new_size = delta_pages * wasm::WasmModule::kPageSize; | 628 new_size = delta_pages * wasm::WasmModule::kPageSize; |
629 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte))); | 629 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte))); |
630 if (!new_mem_start) { | 630 if (!new_mem_start) { |
631 return -1; | 631 return -1; |
632 } | 632 } |
633 } else { | 633 } else { |
634 DCHECK_NOT_NULL(instance->mem_start); | 634 DCHECK_NOT_NULL(instance->mem_start); |
635 new_size = old_size + delta_pages * wasm::WasmModule::kPageSize; | 635 new_size = old_size + delta_pages * wasm::WasmModule::kPageSize; |
636 if (new_size / wasm::WasmModule::kPageSize > wasm::kV8MaxWasmMemoryPages || | 636 if (new_size / wasm::WasmModule::kPageSize > FLAG_wasm_max_mem_pages || |
637 new_size / wasm::WasmModule::kPageSize > | 637 new_size / wasm::WasmModule::kPageSize > |
638 instance->module->max_mem_pages) { | 638 instance->module->max_mem_pages) { |
639 return -1; | 639 return -1; |
640 } | 640 } |
641 new_mem_start = static_cast<byte*>(realloc(instance->mem_start, new_size)); | 641 new_mem_start = static_cast<byte*>(realloc(instance->mem_start, new_size)); |
642 if (!new_mem_start) { | 642 if (!new_mem_start) { |
643 return -1; | 643 return -1; |
644 } | 644 } |
645 // Zero initializing uninitialized memory from realloc | 645 // Zero initializing uninitialized memory from realloc |
646 memset(new_mem_start + old_size, 0, new_size - old_size); | 646 memset(new_mem_start + old_size, 0, new_size - old_size); |
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 return none; | 1909 return none; |
1910 } | 1910 } |
1911 | 1911 |
1912 void InterpretedFrame::SetLocalVal(int index, WasmVal val) { UNIMPLEMENTED(); } | 1912 void InterpretedFrame::SetLocalVal(int index, WasmVal val) { UNIMPLEMENTED(); } |
1913 | 1913 |
1914 void InterpretedFrame::SetExprVal(int pc, WasmVal val) { UNIMPLEMENTED(); } | 1914 void InterpretedFrame::SetExprVal(int pc, WasmVal val) { UNIMPLEMENTED(); } |
1915 | 1915 |
1916 } // namespace wasm | 1916 } // namespace wasm |
1917 } // namespace internal | 1917 } // namespace internal |
1918 } // namespace v8 | 1918 } // namespace v8 |
OLD | NEW |