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

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

Issue 1704033002: [wasm] WasmRunner can run tests with I64 parameters and return value. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@new_wasm_runner
Patch Set: Created 4 years, 10 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
« src/compiler/linkage.h ('K') | « test/cctest/wasm/test-run-wasm.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 <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 TreeResult result = BuildTFGraph(&builder, env, start, end); 236 TreeResult result = BuildTFGraph(&builder, env, start, end);
237 if (result.failed()) { 237 if (result.failed()) {
238 ptrdiff_t pc = result.error_pc - result.start; 238 ptrdiff_t pc = result.error_pc - result.start;
239 ptrdiff_t pt = result.error_pt - result.start; 239 ptrdiff_t pt = result.error_pt - result.start;
240 std::ostringstream str; 240 std::ostringstream str;
241 str << "Verification failed: " << result.error_code << " pc = +" << pc; 241 str << "Verification failed: " << result.error_code << " pc = +" << pc;
242 if (result.error_pt) str << ", pt = +" << pt; 242 if (result.error_pt) str << ", pt = +" << pt;
243 str << ", msg = " << result.error_msg.get(); 243 str << ", msg = " << result.error_msg.get();
244 FATAL(str.str().c_str()); 244 FATAL(str.str().c_str());
245 } 245 }
246 builder.Int64LoweringForTesting(); 246 builder.Int64LoweringForTesting(env->sig);
247 if (FLAG_trace_turbo_graph) { 247 if (FLAG_trace_turbo_graph) {
248 OFStream os(stdout); 248 OFStream os(stdout);
249 os << AsRPO(*jsgraph->graph()); 249 os << AsRPO(*jsgraph->graph());
250 } 250 }
251 } 251 }
252 252
253 template <typename ReturnType> 253 template <typename ReturnType>
254 class WasmFunctionWrapper : public HandleAndZoneScope, 254 class WasmFunctionWrapper : public HandleAndZoneScope,
255 private GraphAndBuilders { 255 private GraphAndBuilders {
256 public: 256 public:
257 WasmFunctionWrapper() 257 WasmFunctionWrapper()
258 : GraphAndBuilders(main_zone()), 258 : GraphAndBuilders(main_zone()),
259 inner_code_node_(nullptr), 259 inner_code_node_(nullptr),
260 signature_(nullptr) { 260 signature_(nullptr) {
261 Signature<MachineType>::Builder sig_builder(zone(), 1, 5); 261 Signature<MachineType>::Builder sig_builder(zone(), 1, 5);
262 262
263 sig_builder.AddReturn(MachineType::Int32()); 263 sig_builder.AddReturn(MachineType::Int32());
264 for (int i = 0; i < 5; i++) { 264 for (int i = 0; i < 5; i++) {
265 sig_builder.AddParam(MachineType::Pointer()); 265 sig_builder.AddParam(MachineType::Pointer());
266 } 266 }
267 signature_ = sig_builder.Build(); 267 signature_ = sig_builder.Build();
268 } 268 }
269 269
270 void Init(CallDescriptor* descriptor, MachineType p0 = MachineType::None(), 270 void Init(const CallDescriptor* descriptor,
271 MachineType p0 = MachineType::None(),
271 MachineType p1 = MachineType::None(), 272 MachineType p1 = MachineType::None(),
272 MachineType p2 = MachineType::None(), 273 MachineType p2 = MachineType::None(),
273 MachineType p3 = MachineType::None()) { 274 MachineType p3 = MachineType::None()) {
274 // Create the TF graph for the wrapper. The wrapper always takes four 275 // Create the TF graph for the wrapper. The wrapper always takes four
275 // pointers as parameters, but may not pass the values of all pointers to 276 // pointers as parameters, but may not pass the values of all pointers to
276 // the actual test function. 277 // the actual test function.
277 278
278 // Function, effect, and control. 279 // Function, effect, and control.
279 Node** parameters = zone()->template NewArray<Node*>(4 + 3); 280 Node** parameters = zone()->template NewArray<Node*>(4 + 3);
280 graph()->SetStart(graph()->NewNode(common()->Start(6))); 281 graph()->SetStart(graph()->NewNode(common()->Start(6)));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 common()->HeapConstant(code_handle)); 342 common()->HeapConstant(code_handle));
342 } 343 }
343 344
344 Handle<Code> GetWrapperCode() { 345 Handle<Code> GetWrapperCode() {
345 if (code_.is_null()) { 346 if (code_.is_null()) {
346 Isolate* isolate = CcTest::InitIsolateOnce(); 347 Isolate* isolate = CcTest::InitIsolateOnce();
347 348
348 CallDescriptor* descriptor = 349 CallDescriptor* descriptor =
349 Linkage::GetSimplifiedCDescriptor(zone(), signature_, true); 350 Linkage::GetSimplifiedCDescriptor(zone(), signature_, true);
350 351
352 #if !WASM_64
353
354 Signature<MachineRepresentation>::Builder rep_builder(zone(), 1, 4);
355
356 rep_builder.AddReturn(MachineRepresentation::kWord32);
357 for (int i = 0; i < 4; i++) {
358 rep_builder.AddParam(MachineRepresentation::kWord32);
359 }
360 Int64Lowering r(graph(), machine(), common(), zone(),
361 rep_builder.Build());
362 r.LowerGraph();
363 #endif
364
351 CompilationInfo info("testing", isolate, graph()->zone()); 365 CompilationInfo info("testing", isolate, graph()->zone());
352 code_ = 366 code_ =
353 Pipeline::GenerateCodeForTesting(&info, descriptor, graph(), nullptr); 367 Pipeline::GenerateCodeForTesting(&info, descriptor, graph(), nullptr);
354 CHECK(!code_.is_null()); 368 CHECK(!code_.is_null());
355 #ifdef ENABLE_DISASSEMBLER 369 #ifdef ENABLE_DISASSEMBLER
356 if (FLAG_print_opt_code) { 370 if (FLAG_print_opt_code) {
357 OFStream os(stdout); 371 OFStream os(stdout);
358 code_->Disassemble("wasm wrapper", os); 372 code_->Disassemble("wasm wrapper", os);
359 } 373 }
360 #endif 374 #endif
(...skipping 19 matching lines...) Expand all
380 jsgraph(this->isolate(), this->graph(), this->common(), nullptr, 394 jsgraph(this->isolate(), this->graph(), this->common(), nullptr,
381 nullptr, this->machine()), 395 nullptr, this->machine()),
382 descriptor_(nullptr) { 396 descriptor_(nullptr) {
383 init_env(&env, sig); 397 init_env(&env, sig);
384 env.module = module; 398 env.module = module;
385 } 399 }
386 400
387 JSGraph jsgraph; 401 JSGraph jsgraph;
388 FunctionEnv env; 402 FunctionEnv env;
389 // The call descriptor is initialized when the function is compiled. 403 // The call descriptor is initialized when the function is compiled.
390 CallDescriptor* descriptor_; 404 const CallDescriptor* descriptor_;
391 405
392 Isolate* isolate() { return main_isolate(); } 406 Isolate* isolate() { return main_isolate(); }
393 Graph* graph() const { return main_graph_; } 407 Graph* graph() const { return main_graph_; }
394 Zone* zone() const { return graph()->zone(); } 408 Zone* zone() const { return graph()->zone(); }
395 CommonOperatorBuilder* common() { return &main_common_; } 409 CommonOperatorBuilder* common() { return &main_common_; }
396 MachineOperatorBuilder* machine() { return &main_machine_; } 410 MachineOperatorBuilder* machine() { return &main_machine_; }
397 void InitializeDescriptor() { 411 void InitializeDescriptor() {
398 if (descriptor_ == nullptr) { 412 if (descriptor_ == nullptr) {
399 descriptor_ = env.module->GetWasmCallDescriptor(main_zone(), env.sig); 413 descriptor_ = env.module->GetWasmCallDescriptor(main_zone(), env.sig);
400 } 414 }
401 } 415 }
402 CallDescriptor* descriptor() { return descriptor_; } 416 const CallDescriptor* descriptor() { return descriptor_; }
403 417
404 void Build(const byte* start, const byte* end) { 418 void Build(const byte* start, const byte* end) {
405 TestBuildingGraph(main_zone(), &jsgraph, &env, start, end); 419 TestBuildingGraph(main_zone(), &jsgraph, &env, start, end);
406 } 420 }
407 421
408 byte AllocateLocal(LocalType type) { 422 byte AllocateLocal(LocalType type) {
409 int result = static_cast<int>(env.total_locals); 423 int result = static_cast<int>(env.total_locals);
410 env.AddLocals(type, 1); 424 env.AddLocals(type, 1);
411 byte b = static_cast<byte>(result); 425 byte b = static_cast<byte>(result);
412 CHECK_EQ(result, b); 426 CHECK_EQ(result, b);
413 return b; 427 return b;
414 } 428 }
415 429
416 Handle<Code> Compile(ModuleEnv* module) { 430 Handle<Code> Compile(ModuleEnv* module) {
417 InitializeDescriptor(); 431 InitializeDescriptor();
432 const CallDescriptor* desc = descriptor_;
433 #if !WASM_64
434 desc = module->GetI32WasmCallDescriptor(this->zone(), desc);
435 #endif
418 CompilationInfo info("wasm compile", this->isolate(), this->zone()); 436 CompilationInfo info("wasm compile", this->isolate(), this->zone());
419 Handle<Code> result = 437 Handle<Code> result =
420 Pipeline::GenerateCodeForTesting(&info, descriptor_, this->graph()); 438 Pipeline::GenerateCodeForTesting(&info, desc, this->graph());
421 #ifdef ENABLE_DISASSEMBLER 439 #ifdef ENABLE_DISASSEMBLER
422 if (!result.is_null() && FLAG_print_opt_code) { 440 if (!result.is_null() && FLAG_print_opt_code) {
423 OFStream os(stdout); 441 OFStream os(stdout);
424 result->Disassemble("wasm code", os); 442 result->Disassemble("wasm code", os);
425 } 443 }
426 #endif 444 #endif
427 445
428 return result; 446 return result;
429 } 447 }
430 448
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 if (p1 == MachineType::None()) return 1; 556 if (p1 == MachineType::None()) return 1;
539 if (p2 == MachineType::None()) return 2; 557 if (p2 == MachineType::None()) return 2;
540 if (p3 == MachineType::None()) return 3; 558 if (p3 == MachineType::None()) return 3;
541 return 4; 559 return 4;
542 } 560 }
543 }; 561 };
544 562
545 } // namespace 563 } // namespace
546 564
547 #endif 565 #endif
OLDNEW
« src/compiler/linkage.h ('K') | « test/cctest/wasm/test-run-wasm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698