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

Side by Side Diff: test/cctest/wasm/test-run-wasm-module.cc

Issue 1775123003: [wasm] Encode immediates to Load and Store as varint. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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.cc ('k') | test/mjsunit/wasm/module-memory.js » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "src/wasm/encoder.h" 8 #include "src/wasm/encoder.h"
9 #include "src/wasm/wasm-js.h" 9 #include "src/wasm/wasm-js.h"
10 #include "src/wasm/wasm-macro-gen.h" 10 #include "src/wasm/wasm-macro-gen.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 uint16_t localIndex = f->AddLocal(kAstI32); 141 uint16_t localIndex = f->AddLocal(kAstI32);
142 f->Exported(1); 142 f->Exported(1);
143 byte code[] = {WASM_BLOCK( 143 byte code[] = {WASM_BLOCK(
144 2, 144 2,
145 WASM_WHILE( 145 WASM_WHILE(
146 WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I32V_3(kCheckSize)), 146 WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I32V_3(kCheckSize)),
147 WASM_IF_ELSE( 147 WASM_IF_ELSE(
148 WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(localIndex)), 148 WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(localIndex)),
149 WASM_BRV(2, WASM_I8(-1)), WASM_INC_LOCAL_BY(localIndex, 4))), 149 WASM_BRV(2, WASM_I8(-1)), WASM_INC_LOCAL_BY(localIndex, 4))),
150 WASM_I8(11))}; 150 WASM_I8(11))};
151 uint32_t local_indices[] = {7, 18, 24, 27}; 151 f->EmitCode(code, sizeof(code), nullptr, 0);
152 f->EmitCode(code, sizeof(code), local_indices, sizeof(local_indices) / 4);
153 WasmModuleWriter* writer = builder->Build(&zone); 152 WasmModuleWriter* writer = builder->Build(&zone);
154 TestModule(writer->WriteTo(&zone), 11); 153 TestModule(writer->WriteTo(&zone), 11);
155 } 154 }
156 #endif 155 #endif
157 156
158 157
159 #if !defined(V8_WITH_ASAN) 158 #if !defined(V8_WITH_ASAN)
160 // TODO(bradnelson): Figure out why this crashes under asan. 159 // TODO(bradnelson): Figure out why this crashes under asan.
161 TEST(Run_WasmModule_CallMain_recursive) { 160 TEST(Run_WasmModule_CallMain_recursive) {
162 Zone zone; 161 Zone zone;
163 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); 162 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
164 uint16_t f_index = builder->AddFunction(); 163 uint16_t f_index = builder->AddFunction();
165 WasmFunctionBuilder* f = builder->FunctionAt(f_index); 164 WasmFunctionBuilder* f = builder->FunctionAt(f_index);
166 f->ReturnType(kAstI32); 165 f->ReturnType(kAstI32);
167 uint16_t localIndex = f->AddLocal(kAstI32); 166 uint16_t localIndex = f->AddLocal(kAstI32);
168 f->Exported(1); 167 f->Exported(1);
169 byte code[] = {WASM_BLOCK( 168 byte code[] = {WASM_BLOCK(
170 2, WASM_SET_LOCAL(localIndex, 169 2, WASM_SET_LOCAL(localIndex,
171 WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)), 170 WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
172 WASM_IF_ELSE(WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I8(5)), 171 WASM_IF_ELSE(WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I8(5)),
173 WASM_BLOCK(2, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, 172 WASM_BLOCK(2, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO,
174 WASM_INC_LOCAL(localIndex)), 173 WASM_INC_LOCAL(localIndex)),
175 WASM_BRV(1, WASM_CALL_FUNCTION0(0))), 174 WASM_BRV(1, WASM_CALL_FUNCTION0(0))),
176 WASM_BRV(0, WASM_I8(55))))}; 175 WASM_BRV(0, WASM_I8(55))))};
177 uint32_t local_indices[] = {3, 11, 21, 24}; 176 f->EmitCode(code, sizeof(code), nullptr, 0);
178 f->EmitCode(code, sizeof(code), local_indices, sizeof(local_indices) / 4);
179 WasmModuleWriter* writer = builder->Build(&zone); 177 WasmModuleWriter* writer = builder->Build(&zone);
180 TestModule(writer->WriteTo(&zone), 55); 178 TestModule(writer->WriteTo(&zone), 55);
181 } 179 }
182 #endif 180 #endif
183 181
184 182
185 #if !defined(V8_WITH_ASAN) 183 #if !defined(V8_WITH_ASAN)
186 // TODO(bradnelson): Figure out why this crashes under asan. 184 // TODO(bradnelson): Figure out why this crashes under asan.
187 TEST(Run_WasmModule_Global) { 185 TEST(Run_WasmModule_Global) {
188 Zone zone; 186 Zone zone;
(...skipping 13 matching lines...) Expand all
202 byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32V_1(56)), 200 byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32V_1(56)),
203 WASM_STORE_GLOBAL(global2, WASM_I32V_1(41)), 201 WASM_STORE_GLOBAL(global2, WASM_I32V_1(41)),
204 WASM_RETURN(WASM_CALL_FUNCTION0(f1_index))}; 202 WASM_RETURN(WASM_CALL_FUNCTION0(f1_index))};
205 f->EmitCode(code2, sizeof(code2)); 203 f->EmitCode(code2, sizeof(code2));
206 WasmModuleWriter* writer = builder->Build(&zone); 204 WasmModuleWriter* writer = builder->Build(&zone);
207 TestModule(writer->WriteTo(&zone), 97); 205 TestModule(writer->WriteTo(&zone), 97);
208 } 206 }
209 #endif 207 #endif
210 208
211 #endif // !V8_TARGET_ARCH_ARM64 209 #endif // !V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm.cc ('k') | test/mjsunit/wasm/module-memory.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698