OLD | NEW |
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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 375 |
376 rep_builder.AddReturn(MachineRepresentation::kWord32); | 376 rep_builder.AddReturn(MachineRepresentation::kWord32); |
377 for (int i = 0; i < WASM_RUNNER_MAX_NUM_PARAMETERS + 1; i++) { | 377 for (int i = 0; i < WASM_RUNNER_MAX_NUM_PARAMETERS + 1; i++) { |
378 rep_builder.AddParam(MachineRepresentation::kWord32); | 378 rep_builder.AddParam(MachineRepresentation::kWord32); |
379 } | 379 } |
380 Int64Lowering r(graph(), machine(), common(), zone(), | 380 Int64Lowering r(graph(), machine(), common(), zone(), |
381 rep_builder.Build()); | 381 rep_builder.Build()); |
382 r.LowerGraph(); | 382 r.LowerGraph(); |
383 } | 383 } |
384 | 384 |
385 CompilationInfo info("testing", isolate, graph()->zone()); | 385 CompilationInfo info(ArrayVector("testing"), isolate, graph()->zone()); |
386 code_ = | 386 code_ = |
387 Pipeline::GenerateCodeForTesting(&info, descriptor, graph(), nullptr); | 387 Pipeline::GenerateCodeForTesting(&info, descriptor, graph(), nullptr); |
388 CHECK(!code_.is_null()); | 388 CHECK(!code_.is_null()); |
389 #ifdef ENABLE_DISASSEMBLER | 389 #ifdef ENABLE_DISASSEMBLER |
390 if (FLAG_print_opt_code) { | 390 if (FLAG_print_opt_code) { |
391 OFStream os(stdout); | 391 OFStream os(stdout); |
392 code_->Disassemble("wasm wrapper", os); | 392 code_->Disassemble("wasm wrapper", os); |
393 } | 393 } |
394 #endif | 394 #endif |
395 } | 395 } |
396 | 396 |
397 return code_; | 397 return code_; |
398 } | 398 } |
399 | 399 |
400 Signature<MachineType>* signature() const { return signature_; } | 400 Signature<MachineType>* signature() const { return signature_; } |
401 | 401 |
402 private: | 402 private: |
403 Node* inner_code_node_; | 403 Node* inner_code_node_; |
404 Handle<Code> code_; | 404 Handle<Code> code_; |
405 Signature<MachineType>* signature_; | 405 Signature<MachineType>* signature_; |
406 }; | 406 }; |
407 | 407 |
408 // A helper for compiling WASM functions for testing. This class can create a | 408 // A helper for compiling WASM functions for testing. This class can create a |
409 // standalone function if {module} is NULL or a function within a | 409 // standalone function if {module} is NULL or a function within a |
410 // {TestingModule}. It contains the internal state for compilation (i.e. | 410 // {TestingModule}. It contains the internal state for compilation (i.e. |
411 // TurboFan graph) and, later, interpretation. | 411 // TurboFan graph) and, later, interpretation. |
412 class WasmFunctionCompiler : public HandleAndZoneScope, | 412 class WasmFunctionCompiler : public HandleAndZoneScope, |
413 private GraphAndBuilders { | 413 private GraphAndBuilders { |
414 public: | 414 public: |
415 explicit WasmFunctionCompiler(FunctionSig* sig, TestingModule* module, | 415 explicit WasmFunctionCompiler( |
416 const char* debug_name = "<WASM UNNAMED>") | 416 FunctionSig* sig, TestingModule* module, |
| 417 Vector<const char> debug_name = ArrayVector("<WASM UNNAMED>")) |
417 : GraphAndBuilders(main_zone()), | 418 : GraphAndBuilders(main_zone()), |
418 jsgraph(this->isolate(), this->graph(), this->common(), nullptr, | 419 jsgraph(this->isolate(), this->graph(), this->common(), nullptr, |
419 nullptr, this->machine()), | 420 nullptr, this->machine()), |
420 sig(sig), | 421 sig(sig), |
421 descriptor_(nullptr), | 422 descriptor_(nullptr), |
422 testing_module_(module), | 423 testing_module_(module), |
423 debug_name_(debug_name), | 424 debug_name_(debug_name), |
424 source_position_table_(this->graph()) { | 425 source_position_table_(this->graph()) { |
425 if (module) { | 426 if (module) { |
426 // Get a new function from the testing module. | 427 // Get a new function from the testing module. |
427 function_ = nullptr; | 428 function_ = nullptr; |
428 function_index_ = module->AddFunction(sig, Handle<Code>::null()); | 429 function_index_ = module->AddFunction(sig, Handle<Code>::null()); |
429 } else { | 430 } else { |
430 // Create our own function. | 431 // Create our own function. |
431 function_ = new WasmFunction(); | 432 function_ = new WasmFunction(); |
432 function_->sig = sig; | 433 function_->sig = sig; |
433 function_index_ = 0; | 434 function_index_ = 0; |
434 } | 435 } |
435 } | 436 } |
436 | 437 |
437 ~WasmFunctionCompiler() { | 438 ~WasmFunctionCompiler() { |
438 if (function_) delete function_; | 439 if (function_) delete function_; |
439 } | 440 } |
440 | 441 |
441 JSGraph jsgraph; | 442 JSGraph jsgraph; |
442 FunctionSig* sig; | 443 FunctionSig* sig; |
443 // The call descriptor is initialized when the function is compiled. | 444 // The call descriptor is initialized when the function is compiled. |
444 CallDescriptor* descriptor_; | 445 CallDescriptor* descriptor_; |
445 TestingModule* testing_module_; | 446 TestingModule* testing_module_; |
446 const char* debug_name_; | 447 Vector<const char> debug_name_; |
447 WasmFunction* function_; | 448 WasmFunction* function_; |
448 int function_index_; | 449 int function_index_; |
449 LocalDeclEncoder local_decls; | 450 LocalDeclEncoder local_decls; |
450 SourcePositionTable source_position_table_; | 451 SourcePositionTable source_position_table_; |
451 | 452 |
452 Isolate* isolate() { return main_isolate(); } | 453 Isolate* isolate() { return main_isolate(); } |
453 Graph* graph() const { return main_graph_; } | 454 Graph* graph() const { return main_graph_; } |
454 Zone* zone() const { return graph()->zone(); } | 455 Zone* zone() const { return graph()->zone(); } |
455 CommonOperatorBuilder* common() { return &main_common_; } | 456 CommonOperatorBuilder* common() { return &main_common_; } |
456 MachineOperatorBuilder* machine() { return &main_machine_; } | 457 MachineOperatorBuilder* machine() { return &main_machine_; } |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 if (p1 == MachineType::None()) return 1; | 647 if (p1 == MachineType::None()) return 1; |
647 if (p2 == MachineType::None()) return 2; | 648 if (p2 == MachineType::None()) return 2; |
648 if (p3 == MachineType::None()) return 3; | 649 if (p3 == MachineType::None()) return 3; |
649 return 4; | 650 return 4; |
650 } | 651 } |
651 }; | 652 }; |
652 | 653 |
653 } // namespace | 654 } // namespace |
654 | 655 |
655 #endif | 656 #endif |
OLD | NEW |