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

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

Issue 2626313003: [wasm] Change the constant kV8MaxWasmMemoryPages to a command line flag. (Closed)
Patch Set: allow all unsigned ints 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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 } 611 }
612 612
613 static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) { 613 static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) {
614 return bit_cast<int64_t>(a); 614 return bit_cast<int64_t>(a);
615 } 615 }
616 616
617 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages, 617 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages,
618 WasmInstance* instance) { 618 WasmInstance* instance) {
619 // TODO(ahaas): Move memory allocation to wasm-module.cc for better 619 // TODO(ahaas): Move memory allocation to wasm-module.cc for better
620 // encapsulation. 620 // encapsulation.
621 if (delta_pages > wasm::kV8MaxWasmMemoryPages || 621 if (delta_pages > FLAG_wasm_max_mem_pages ||
622 delta_pages > instance->module->max_mem_pages) { 622 delta_pages > instance->module->max_mem_pages) {
623 return -1; 623 return -1;
624 } 624 }
625 uint32_t old_size = instance->mem_size; 625 uint32_t old_size = instance->mem_size;
626 uint32_t new_size; 626 uint32_t new_size;
627 byte* new_mem_start; 627 byte* new_mem_start;
628 if (instance->mem_size == 0) { 628 if (instance->mem_size == 0) {
629 // TODO(gdeepti): Fix bounds check to take into account size of memtype. 629 // TODO(gdeepti): Fix bounds check to take into account size of memtype.
630 new_size = delta_pages * wasm::WasmModule::kPageSize; 630 new_size = delta_pages * wasm::WasmModule::kPageSize;
631 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte))); 631 new_mem_start = static_cast<byte*>(calloc(new_size, sizeof(byte)));
632 if (!new_mem_start) { 632 if (!new_mem_start) {
633 return -1; 633 return -1;
634 } 634 }
635 } else { 635 } else {
636 DCHECK_NOT_NULL(instance->mem_start); 636 DCHECK_NOT_NULL(instance->mem_start);
637 new_size = old_size + delta_pages * wasm::WasmModule::kPageSize; 637 new_size = old_size + delta_pages * wasm::WasmModule::kPageSize;
638 if (new_size / wasm::WasmModule::kPageSize > wasm::kV8MaxWasmMemoryPages || 638 if (new_size / wasm::WasmModule::kPageSize > FLAG_wasm_max_mem_pages ||
639 new_size / wasm::WasmModule::kPageSize > 639 new_size / wasm::WasmModule::kPageSize >
640 instance->module->max_mem_pages) { 640 instance->module->max_mem_pages) {
641 return -1; 641 return -1;
642 } 642 }
643 new_mem_start = static_cast<byte*>(realloc(instance->mem_start, new_size)); 643 new_mem_start = static_cast<byte*>(realloc(instance->mem_start, new_size));
644 if (!new_mem_start) { 644 if (!new_mem_start) {
645 return -1; 645 return -1;
646 } 646 }
647 // Zero initializing uninitialized memory from realloc 647 // Zero initializing uninitialized memory from realloc
648 memset(new_mem_start + old_size, 0, new_size - old_size); 648 memset(new_mem_start + old_size, 0, new_size - old_size);
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 1881
1882 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( 1882 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting(
1883 Zone* zone, const byte* start, const byte* end) { 1883 Zone* zone, const byte* start, const byte* end) {
1884 ControlTransfers targets(zone, nullptr, start, end); 1884 ControlTransfers targets(zone, nullptr, start, end);
1885 return targets.map_; 1885 return targets.map_;
1886 } 1886 }
1887 1887
1888 } // namespace wasm 1888 } // namespace wasm
1889 } // namespace internal 1889 } // namespace internal
1890 } // namespace v8 1890 } // namespace v8
OLDNEW
« src/flags.cc ('K') | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698