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

Side by Side Diff: test/cctest/wasm/wasm-run-utils.h

Issue 2627943002: [wasm] The interpreter should not grow memory beyond module->mem_max_pages. (Closed)
Patch Set: Comments addressed 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
« no previous file with comments | « test/cctest/wasm/test-run-wasm-interpreter.cc ('k') | no next file » | 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 #ifndef WASM_RUN_UTILS_H 5 #ifndef WASM_RUN_UTILS_H
6 #define WASM_RUN_UTILS_H 6 #define WASM_RUN_UTILS_H
7 7
8 #include <setjmp.h> 8 #include <setjmp.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 // Pseudo-randomly intialize the memory. 175 // Pseudo-randomly intialize the memory.
176 void RandomizeMemory(unsigned int seed = 88) { 176 void RandomizeMemory(unsigned int seed = 88) {
177 byte* raw = raw_mem_start<byte>(); 177 byte* raw = raw_mem_start<byte>();
178 byte* end = raw_mem_end<byte>(); 178 byte* end = raw_mem_end<byte>();
179 v8::base::RandomNumberGenerator rng; 179 v8::base::RandomNumberGenerator rng;
180 rng.SetSeed(seed); 180 rng.SetSeed(seed);
181 rng.NextBytes(raw, end - raw); 181 rng.NextBytes(raw, end - raw);
182 } 182 }
183 183
184 void SetMaxMemPages(uint32_t max_mem_pages) {
185 module_.max_mem_pages = max_mem_pages;
186 }
187
184 uint32_t AddFunction(FunctionSig* sig, Handle<Code> code, const char* name) { 188 uint32_t AddFunction(FunctionSig* sig, Handle<Code> code, const char* name) {
185 if (module->functions.size() == 0) { 189 if (module->functions.size() == 0) {
186 // TODO(titzer): Reserving space here to avoid the underlying WasmFunction 190 // TODO(titzer): Reserving space here to avoid the underlying WasmFunction
187 // structs from moving. 191 // structs from moving.
188 module_.functions.reserve(kMaxFunctions); 192 module_.functions.reserve(kMaxFunctions);
189 } 193 }
190 uint32_t index = static_cast<uint32_t>(module->functions.size()); 194 uint32_t index = static_cast<uint32_t>(module->functions.size());
191 module_.functions.push_back({sig, index, 0, 0, 0, 0, 0, false, false}); 195 module_.functions.push_back({sig, index, 0, 0, 0, 0, 0, false, false});
192 if (name) { 196 if (name) {
193 Vector<const byte> name_vec = Vector<const byte>::cast(CStrVector(name)); 197 Vector<const byte> name_vec = Vector<const byte>::cast(CStrVector(name));
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 void RunWasm_##name(WasmExecutionMode execution_mode) 800 void RunWasm_##name(WasmExecutionMode execution_mode)
797 801
798 #define WASM_EXEC_COMPILED_TEST(name) \ 802 #define WASM_EXEC_COMPILED_TEST(name) \
799 void RunWasm_##name(WasmExecutionMode execution_mode); \ 803 void RunWasm_##name(WasmExecutionMode execution_mode); \
800 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ 804 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
801 void RunWasm_##name(WasmExecutionMode execution_mode) 805 void RunWasm_##name(WasmExecutionMode execution_mode)
802 806
803 } // namespace 807 } // namespace
804 808
805 #endif 809 #endif
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-interpreter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698