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

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

Issue 2626313003: [wasm] Change the constant kV8MaxWasmMemoryPages to a command line flag. (Closed)
Patch Set: typo Created 3 years, 11 months 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
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/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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 } 657 }
658 658
659 static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) { 659 static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) {
660 return bit_cast<int64_t>(a); 660 return bit_cast<int64_t>(a);
661 } 661 }
662 662
663 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages, 663 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages,
664 WasmInstance* instance) { 664 WasmInstance* instance) {
665 // TODO(ahaas): Move memory allocation to wasm-module.cc for better 665 // TODO(ahaas): Move memory allocation to wasm-module.cc for better
666 // encapsulation. 666 // encapsulation.
667 if (delta_pages > wasm::kV8MaxWasmMemoryPages || 667 if (delta_pages > static_cast<uint32_t>(FLAG_wasm_max_mem_pages) ||
668 delta_pages > instance->module->max_mem_pages) { 668 delta_pages > instance->module->max_mem_pages) {
669 return -1; 669 return -1;
670 } 670 }
671 uint32_t old_size = instance->mem_size; 671 uint32_t old_size = instance->mem_size;
672 uint32_t new_size; 672 uint32_t new_size;
673 byte* new_mem_start; 673 byte* new_mem_start;
674 if (instance->mem_size == 0) { 674 if (instance->mem_size == 0) {
675 // TODO(gdeepti): Fix bounds check to take into account size of memtype. 675 // TODO(gdeepti): Fix bounds check to take into account size of memtype.
676 new_size = delta_pages * wasm::WasmModule::kPageSize; 676 new_size = delta_pages * wasm::WasmModule::kPageSize;
677 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte))); 677 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte)));
678 if (!new_mem_start) { 678 if (!new_mem_start) {
679 return -1; 679 return -1;
680 } 680 }
681 } else { 681 } else {
682 DCHECK_NOT_NULL(instance->mem_start); 682 DCHECK_NOT_NULL(instance->mem_start);
683 new_size = old_size + delta_pages * wasm::WasmModule::kPageSize; 683 new_size = old_size + delta_pages * wasm::WasmModule::kPageSize;
684 if (new_size / wasm::WasmModule::kPageSize > wasm::kV8MaxWasmMemoryPages || 684 if (new_size / wasm::WasmModule::kPageSize >
685 static_cast<uint32_t>(FLAG_wasm_max_mem_pages) ||
685 new_size / wasm::WasmModule::kPageSize > 686 new_size / wasm::WasmModule::kPageSize >
686 instance->module->max_mem_pages) { 687 instance->module->max_mem_pages) {
687 return -1; 688 return -1;
688 } 689 }
689 new_mem_start = static_cast<byte*>(realloc(instance->mem_start, new_size)); 690 new_mem_start = static_cast<byte*>(realloc(instance->mem_start, new_size));
690 if (!new_mem_start) { 691 if (!new_mem_start) {
691 return -1; 692 return -1;
692 } 693 }
693 // Zero initializing uninitialized memory from realloc 694 // Zero initializing uninitialized memory from realloc
694 memset(new_mem_start + old_size, 0, new_size - old_size); 695 memset(new_mem_start + old_size, 0, new_size - old_size);
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 1886
1886 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( 1887 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting(
1887 Zone* zone, const byte* start, const byte* end) { 1888 Zone* zone, const byte* start, const byte* end) {
1888 ControlTransfers targets(zone, nullptr, start, end); 1889 ControlTransfers targets(zone, nullptr, start, end);
1889 return targets.map_; 1890 return targets.map_;
1890 } 1891 }
1891 1892
1892 } // namespace wasm 1893 } // namespace wasm
1893 } // namespace internal 1894 } // namespace internal
1894 } // namespace v8 1895 } // namespace v8
OLDNEW
« src/flag-definitions.h ('K') | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-limits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698