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

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

Issue 2640453003: [wasm] Fix and tighten memory validation (Closed)
Patch Set: Comments 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 #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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 ~TestingModule() { 98 ~TestingModule() {
99 if (instance->mem_start) { 99 if (instance->mem_start) {
100 free(instance->mem_start); 100 free(instance->mem_start);
101 } 101 }
102 if (interpreter_) delete interpreter_; 102 if (interpreter_) delete interpreter_;
103 } 103 }
104 104
105 void ChangeOriginToAsmjs() { module_.origin = kAsmJsOrigin; } 105 void ChangeOriginToAsmjs() { module_.origin = kAsmJsOrigin; }
106 106
107 byte* AddMemory(uint32_t size) { 107 byte* AddMemory(uint32_t size) {
108 CHECK(!module_.has_memory);
108 CHECK_NULL(instance->mem_start); 109 CHECK_NULL(instance->mem_start);
109 CHECK_EQ(0, instance->mem_size); 110 CHECK_EQ(0, instance->mem_size);
111 module_.has_memory = true;
110 instance->mem_start = reinterpret_cast<byte*>(malloc(size)); 112 instance->mem_start = reinterpret_cast<byte*>(malloc(size));
111 CHECK(instance->mem_start); 113 CHECK(instance->mem_start);
112 memset(instance->mem_start, 0, size); 114 memset(instance->mem_start, 0, size);
113 instance->mem_size = size; 115 instance->mem_size = size;
114 return raw_mem_start<byte>(); 116 return raw_mem_start<byte>();
115 } 117 }
116 118
117 template <typename T> 119 template <typename T>
118 T* AddMemoryElems(uint32_t count) { 120 T* AddMemoryElems(uint32_t count) {
119 AddMemory(count * sizeof(T)); 121 AddMemory(count * sizeof(T));
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 void RunWasm_##name(WasmExecutionMode execution_mode) 813 void RunWasm_##name(WasmExecutionMode execution_mode)
812 814
813 #define WASM_EXEC_COMPILED_TEST(name) \ 815 #define WASM_EXEC_COMPILED_TEST(name) \
814 void RunWasm_##name(WasmExecutionMode execution_mode); \ 816 void RunWasm_##name(WasmExecutionMode execution_mode); \
815 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ 817 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
816 void RunWasm_##name(WasmExecutionMode execution_mode) 818 void RunWasm_##name(WasmExecutionMode execution_mode)
817 819
818 } // namespace 820 } // namespace
819 821
820 #endif 822 #endif
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-wasm-trap-position.cc ('k') | test/mjsunit/regress/wasm/regression-667745.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698