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

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

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test failures and TSAN races. Created 4 years, 2 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-wasm-trap-position.cc ('k') | test/common/wasm/wasm-module-runner.cc » ('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 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 <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 rng.NextBytes(raw, end - raw); 174 rng.NextBytes(raw, end - raw);
175 } 175 }
176 176
177 uint32_t AddFunction(FunctionSig* sig, Handle<Code> code) { 177 uint32_t AddFunction(FunctionSig* sig, Handle<Code> code) {
178 if (module->functions.size() == 0) { 178 if (module->functions.size() == 0) {
179 // TODO(titzer): Reserving space here to avoid the underlying WasmFunction 179 // TODO(titzer): Reserving space here to avoid the underlying WasmFunction
180 // structs from moving. 180 // structs from moving.
181 module_.functions.reserve(kMaxFunctions); 181 module_.functions.reserve(kMaxFunctions);
182 } 182 }
183 uint32_t index = static_cast<uint32_t>(module->functions.size()); 183 uint32_t index = static_cast<uint32_t>(module->functions.size());
184 module_.functions.push_back({sig, index, 0, 0, 0, 0, 0}); 184 module_.functions.push_back({sig, index, 0, 0, 0, 0, 0, false, false});
185 instance->function_code.push_back(code); 185 instance->function_code.push_back(code);
186 if (interpreter_) { 186 if (interpreter_) {
187 const WasmFunction* function = &module->functions.back(); 187 const WasmFunction* function = &module->functions.back();
188 int interpreter_index = interpreter_->AddFunctionForTesting(function); 188 int interpreter_index = interpreter_->AddFunctionForTesting(function);
189 CHECK_EQ(index, static_cast<uint32_t>(interpreter_index)); 189 CHECK_EQ(index, static_cast<uint32_t>(interpreter_index));
190 } 190 }
191 DCHECK_LT(index, kMaxFunctions); // limited for testing. 191 DCHECK_LT(index, kMaxFunctions); // limited for testing.
192 return index; 192 return index;
193 } 193 }
194 194
(...skipping 28 matching lines...) Expand all
223 exportedSig, module_object); 223 exportedSig, module_object);
224 return ret; 224 return ret;
225 } 225 }
226 226
227 void SetFunctionCode(uint32_t index, Handle<Code> code) { 227 void SetFunctionCode(uint32_t index, Handle<Code> code) {
228 instance->function_code[index] = code; 228 instance->function_code[index] = code;
229 } 229 }
230 230
231 void AddIndirectFunctionTable(uint16_t* functions, uint32_t table_size) { 231 void AddIndirectFunctionTable(uint16_t* functions, uint32_t table_size) {
232 module_.function_tables.push_back( 232 module_.function_tables.push_back(
233 {table_size, table_size, std::vector<uint16_t>()}); 233 {table_size, table_size, std::vector<int32_t>(), false, false});
234 for (uint32_t i = 0; i < table_size; ++i) { 234 for (uint32_t i = 0; i < table_size; ++i) {
235 module_.function_tables.back().values.push_back(functions[i]); 235 module_.function_tables.back().values.push_back(functions[i]);
236 } 236 }
237 237
238 Handle<FixedArray> values = BuildFunctionTable( 238 Handle<FixedArray> values = BuildFunctionTable(
239 isolate_, static_cast<int>(module_.function_tables.size() - 1), 239 isolate_, static_cast<int>(module_.function_tables.size() - 1),
240 &module_); 240 &module_);
241 instance->function_tables.push_back(values); 241 instance->function_tables.push_back(values);
242 } 242 }
243 243
(...skipping 16 matching lines...) Expand all
260 WasmModuleInstance instance_; 260 WasmModuleInstance instance_;
261 Isolate* isolate_; 261 Isolate* isolate_;
262 v8::internal::AccountingAllocator allocator_; 262 v8::internal::AccountingAllocator allocator_;
263 uint32_t global_offset; 263 uint32_t global_offset;
264 V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data. 264 V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data.
265 WasmInterpreter* interpreter_; 265 WasmInterpreter* interpreter_;
266 266
267 const WasmGlobal* AddGlobal(LocalType type) { 267 const WasmGlobal* AddGlobal(LocalType type) {
268 byte size = WasmOpcodes::MemSize(WasmOpcodes::MachineTypeFor(type)); 268 byte size = WasmOpcodes::MemSize(WasmOpcodes::MachineTypeFor(type));
269 global_offset = (global_offset + size - 1) & ~(size - 1); // align 269 global_offset = (global_offset + size - 1) & ~(size - 1); // align
270 module_.globals.push_back({0, 0, type, global_offset, false}); 270 module_.globals.push_back(
271 {type, true, NO_INIT, global_offset, false, false});
271 global_offset += size; 272 global_offset += size;
272 // limit number of globals. 273 // limit number of globals.
273 CHECK_LT(global_offset, kMaxGlobalsSize); 274 CHECK_LT(global_offset, kMaxGlobalsSize);
274 return &module->globals.back(); 275 return &module->globals.back();
275 } 276 }
276 }; 277 };
277 278
278 inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, ModuleEnv* module, 279 inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, ModuleEnv* module,
279 FunctionSig* sig, 280 FunctionSig* sig,
280 SourcePositionTable* source_position_table, 281 SourcePositionTable* source_position_table,
281 const byte* start, const byte* end) { 282 const byte* start, const byte* end) {
282 compiler::WasmGraphBuilder builder(zone, jsgraph, sig, source_position_table); 283 compiler::WasmGraphBuilder builder(zone, jsgraph, sig, source_position_table);
283 DecodeResult result = 284 DecodeResult result =
284 BuildTFGraph(zone->allocator(), &builder, module, sig, start, end); 285 BuildTFGraph(zone->allocator(), &builder, module, sig, start, end);
285 if (result.failed()) { 286 if (result.failed()) {
287 if (!FLAG_trace_wasm_decoder) {
288 // Retry the compilation with the tracing flag on, to help in debugging.
289 FLAG_trace_wasm_decoder = true;
290 result =
291 BuildTFGraph(zone->allocator(), &builder, module, sig, start, end);
292 }
293
286 ptrdiff_t pc = result.error_pc - result.start; 294 ptrdiff_t pc = result.error_pc - result.start;
287 ptrdiff_t pt = result.error_pt - result.start; 295 ptrdiff_t pt = result.error_pt - result.start;
288 std::ostringstream str; 296 std::ostringstream str;
289 str << "Verification failed: " << result.error_code << " pc = +" << pc; 297 str << "Verification failed: " << result.error_code << " pc = +" << pc;
290 if (result.error_pt) str << ", pt = +" << pt; 298 if (result.error_pt) str << ", pt = +" << pt;
291 str << ", msg = " << result.error_msg.get(); 299 str << ", msg = " << result.error_msg.get();
292 FATAL(str.str().c_str()); 300 FATAL(str.str().c_str());
293 } 301 }
294 builder.Int64LoweringForTesting(); 302 builder.Int64LoweringForTesting();
295 if (FLAG_trace_turbo_graph) { 303 if (FLAG_trace_turbo_graph) {
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 // interpreter. 783 // interpreter.
776 #define WASM_EXEC_TEST(name) \ 784 #define WASM_EXEC_TEST(name) \
777 void RunWasm_##name(WasmExecutionMode execution_mode); \ 785 void RunWasm_##name(WasmExecutionMode execution_mode); \
778 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ 786 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
779 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ 787 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \
780 void RunWasm_##name(WasmExecutionMode execution_mode) 788 void RunWasm_##name(WasmExecutionMode execution_mode)
781 789
782 } // namespace 790 } // namespace
783 791
784 #endif 792 #endif
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-wasm-trap-position.cc ('k') | test/common/wasm/wasm-module-runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698