Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: src/wasm/wasm-interpreter.cc

Issue 2456193006: Revert of [wasm] Support for restricted table imports. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-js.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 } 656 }
657 657
658 static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) { 658 static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) {
659 return bit_cast<int64_t>(a); 659 return bit_cast<int64_t>(a);
660 } 660 }
661 661
662 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages, 662 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages,
663 WasmInstance* instance) { 663 WasmInstance* instance) {
664 // TODO(ahaas): Move memory allocation to wasm-module.cc for better 664 // TODO(ahaas): Move memory allocation to wasm-module.cc for better
665 // encapsulation. 665 // encapsulation.
666 if (delta_pages > wasm::WasmModule::kV8MaxPages) { 666 if (delta_pages > wasm::WasmModule::kMaxMemPages) {
667 return -1; 667 return -1;
668 } 668 }
669 uint32_t old_size = instance->mem_size; 669 uint32_t old_size = instance->mem_size;
670 uint32_t new_size; 670 uint32_t new_size;
671 byte* new_mem_start; 671 byte* new_mem_start;
672 if (instance->mem_size == 0) { 672 if (instance->mem_size == 0) {
673 if (delta_pages > wasm::WasmModule::kMaxMemPages) {
674 return -1;
675 }
673 // TODO(gdeepti): Fix bounds check to take into account size of memtype. 676 // TODO(gdeepti): Fix bounds check to take into account size of memtype.
674 new_size = delta_pages * wasm::WasmModule::kPageSize; 677 new_size = delta_pages * wasm::WasmModule::kPageSize;
675 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte))); 678 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte)));
676 if (!new_mem_start) { 679 if (!new_mem_start) {
677 return -1; 680 return -1;
678 } 681 }
679 } else { 682 } else {
680 DCHECK_NOT_NULL(instance->mem_start); 683 DCHECK_NOT_NULL(instance->mem_start);
681 new_size = old_size + delta_pages * wasm::WasmModule::kPageSize; 684 new_size = old_size + delta_pages * wasm::WasmModule::kPageSize;
682 if (new_size > 685 if (new_size >
683 wasm::WasmModule::kV8MaxPages * wasm::WasmModule::kPageSize) { 686 wasm::WasmModule::kMaxMemPages * wasm::WasmModule::kPageSize) {
684 return -1; 687 return -1;
685 } 688 }
686 new_mem_start = static_cast<byte*>(realloc(instance->mem_start, new_size)); 689 new_mem_start = static_cast<byte*>(realloc(instance->mem_start, new_size));
687 if (!new_mem_start) { 690 if (!new_mem_start) {
688 return -1; 691 return -1;
689 } 692 }
690 // Zero initializing uninitialized memory from realloc 693 // Zero initializing uninitialized memory from realloc
691 memset(new_mem_start + old_size, 0, new_size - old_size); 694 memset(new_mem_start + old_size, 0, new_size - old_size);
692 } 695 }
693 instance->mem_start = new_mem_start; 696 instance->mem_start = new_mem_start;
694 instance->mem_size = new_size; 697 instance->mem_size = new_size;
698 // realloc
699 // update mem_start
700 // update mem_size
695 return static_cast<int32_t>(old_size / WasmModule::kPageSize); 701 return static_cast<int32_t>(old_size / WasmModule::kPageSize);
696 } 702 }
697 703
698 enum InternalOpcode { 704 enum InternalOpcode {
699 #define DECL_INTERNAL_ENUM(name, value) kInternal##name = value, 705 #define DECL_INTERNAL_ENUM(name, value) kInternal##name = value,
700 FOREACH_INTERNAL_OPCODE(DECL_INTERNAL_ENUM) 706 FOREACH_INTERNAL_OPCODE(DECL_INTERNAL_ENUM)
701 #undef DECL_INTERNAL_ENUM 707 #undef DECL_INTERNAL_ENUM
702 }; 708 };
703 709
704 static const char* OpcodeName(uint32_t val) { 710 static const char* OpcodeName(uint32_t val) {
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 1885
1880 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( 1886 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting(
1881 Zone* zone, const byte* start, const byte* end) { 1887 Zone* zone, const byte* start, const byte* end) {
1882 ControlTransfers targets(zone, nullptr, nullptr, start, end); 1888 ControlTransfers targets(zone, nullptr, nullptr, start, end);
1883 return targets.map_; 1889 return targets.map_;
1884 } 1890 }
1885 1891
1886 } // namespace wasm 1892 } // namespace wasm
1887 } // namespace internal 1893 } // namespace internal
1888 } // namespace v8 1894 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-js.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698