| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 5 #ifndef V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
| 6 #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 6 #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
| 9 #include "src/compiler/graph-builder.h" | 9 #include "src/compiler/graph.h" |
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| 11 #include "src/compiler/machine-operator.h" | 11 #include "src/compiler/machine-operator.h" |
| 12 #include "src/compiler/node.h" | 12 #include "src/compiler/node.h" |
| 13 #include "src/compiler/operator.h" | 13 #include "src/compiler/operator.h" |
| 14 | 14 |
| 15 | 15 |
| 16 namespace v8 { | 16 namespace v8 { |
| 17 namespace internal { | 17 namespace internal { |
| 18 namespace compiler { | 18 namespace compiler { |
| 19 | 19 |
| 20 class BasicBlock; | 20 class BasicBlock; |
| 21 class Schedule; | 21 class Schedule; |
| 22 | 22 |
| 23 | 23 |
| 24 class RawMachineAssembler : public GraphBuilder { | 24 class RawMachineAssembler { |
| 25 public: | 25 public: |
| 26 class Label { | 26 class Label { |
| 27 public: | 27 public: |
| 28 Label() : block_(NULL), used_(false), bound_(false) {} | 28 Label() : block_(NULL), used_(false), bound_(false) {} |
| 29 ~Label() { DCHECK(bound_ || !used_); } | 29 ~Label() { DCHECK(bound_ || !used_); } |
| 30 | 30 |
| 31 BasicBlock* block() { return block_; } | 31 BasicBlock* block() { return block_; } |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 // Private constructor for exit label. | 34 // Private constructor for exit label. |
| 35 explicit Label(BasicBlock* block) | 35 explicit Label(BasicBlock* block) |
| 36 : block_(block), used_(false), bound_(false) {} | 36 : block_(block), used_(false), bound_(false) {} |
| 37 | 37 |
| 38 BasicBlock* block_; | 38 BasicBlock* block_; |
| 39 bool used_; | 39 bool used_; |
| 40 bool bound_; | 40 bool bound_; |
| 41 friend class RawMachineAssembler; | 41 friend class RawMachineAssembler; |
| 42 DISALLOW_COPY_AND_ASSIGN(Label); | 42 DISALLOW_COPY_AND_ASSIGN(Label); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 RawMachineAssembler(Isolate* isolate, Graph* graph, | 45 RawMachineAssembler(Isolate* isolate, Graph* graph, |
| 46 CallDescriptor* call_descriptor, | 46 CallDescriptor* call_descriptor, |
| 47 MachineType word = kMachPtr, | 47 MachineType word = kMachPtr, |
| 48 MachineOperatorBuilder::Flags flags = | 48 MachineOperatorBuilder::Flags flags = |
| 49 MachineOperatorBuilder::Flag::kNoFlags); | 49 MachineOperatorBuilder::Flag::kNoFlags); |
| 50 ~RawMachineAssembler() override {} | 50 ~RawMachineAssembler() {} |
| 51 | 51 |
| 52 Isolate* isolate() const { return isolate_; } |
| 53 Graph* graph() const { return graph_; } |
| 52 Zone* zone() const { return graph()->zone(); } | 54 Zone* zone() const { return graph()->zone(); } |
| 53 MachineOperatorBuilder* machine() { return &machine_; } | 55 MachineOperatorBuilder* machine() { return &machine_; } |
| 54 CommonOperatorBuilder* common() { return &common_; } | 56 CommonOperatorBuilder* common() { return &common_; } |
| 55 CallDescriptor* call_descriptor() const { return call_descriptor_; } | 57 CallDescriptor* call_descriptor() const { return call_descriptor_; } |
| 56 size_t parameter_count() const { return machine_sig()->parameter_count(); } | 58 size_t parameter_count() const { return machine_sig()->parameter_count(); } |
| 57 const MachineSignature* machine_sig() const { | 59 const MachineSignature* machine_sig() const { |
| 58 return call_descriptor_->GetMachineSignature(); | 60 return call_descriptor_->GetMachineSignature(); |
| 59 } | 61 } |
| 60 | 62 |
| 61 Node* UndefinedConstant() { | 63 Node* UndefinedConstant() { |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3) { | 506 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3) { |
| 505 return NewNode(common()->Phi(type, 3), n1, n2, n3); | 507 return NewNode(common()->Phi(type, 3), n1, n2, n3); |
| 506 } | 508 } |
| 507 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3, Node* n4) { | 509 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3, Node* n4) { |
| 508 return NewNode(common()->Phi(type, 4), n1, n2, n3, n4); | 510 return NewNode(common()->Phi(type, 4), n1, n2, n3, n4); |
| 509 } | 511 } |
| 510 | 512 |
| 511 // MachineAssembler is invalid after export. | 513 // MachineAssembler is invalid after export. |
| 512 Schedule* Export(); | 514 Schedule* Export(); |
| 513 | 515 |
| 516 Node* NewNode(const Operator* op) { |
| 517 return MakeNode(op, 0, static_cast<Node**>(NULL)); |
| 518 } |
| 519 |
| 520 Node* NewNode(const Operator* op, Node* n1) { return MakeNode(op, 1, &n1); } |
| 521 |
| 522 Node* NewNode(const Operator* op, Node* n1, Node* n2) { |
| 523 Node* buffer[] = {n1, n2}; |
| 524 return MakeNode(op, arraysize(buffer), buffer); |
| 525 } |
| 526 |
| 527 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) { |
| 528 Node* buffer[] = {n1, n2, n3}; |
| 529 return MakeNode(op, arraysize(buffer), buffer); |
| 530 } |
| 531 |
| 532 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) { |
| 533 Node* buffer[] = {n1, n2, n3, n4}; |
| 534 return MakeNode(op, arraysize(buffer), buffer); |
| 535 } |
| 536 |
| 537 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, |
| 538 Node* n5) { |
| 539 Node* buffer[] = {n1, n2, n3, n4, n5}; |
| 540 return MakeNode(op, arraysize(buffer), buffer); |
| 541 } |
| 542 |
| 543 Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, |
| 544 Node* n5, Node* n6) { |
| 545 Node* nodes[] = {n1, n2, n3, n4, n5, n6}; |
| 546 return MakeNode(op, arraysize(nodes), nodes); |
| 547 } |
| 548 |
| 549 Node* NewNode(const Operator* op, int value_input_count, |
| 550 Node** value_inputs) { |
| 551 return MakeNode(op, value_input_count, value_inputs); |
| 552 } |
| 553 |
| 514 protected: | 554 protected: |
| 515 Node* MakeNode(const Operator* op, int input_count, Node** inputs, | 555 Node* MakeNode(const Operator* op, int input_count, Node** inputs); |
| 516 bool incomplete) final; | |
| 517 | 556 |
| 518 bool ScheduleValid() { return schedule_ != NULL; } | 557 bool ScheduleValid() { return schedule_ != NULL; } |
| 519 | 558 |
| 520 Schedule* schedule() { | 559 Schedule* schedule() { |
| 521 DCHECK(ScheduleValid()); | 560 DCHECK(ScheduleValid()); |
| 522 return schedule_; | 561 return schedule_; |
| 523 } | 562 } |
| 524 | 563 |
| 525 private: | 564 private: |
| 526 BasicBlock* Use(Label* label); | 565 BasicBlock* Use(Label* label); |
| 527 BasicBlock* EnsureBlock(Label* label); | 566 BasicBlock* EnsureBlock(Label* label); |
| 528 BasicBlock* CurrentBlock(); | 567 BasicBlock* CurrentBlock(); |
| 529 | 568 |
| 569 Isolate* isolate_; |
| 570 Graph* graph_; |
| 530 Schedule* schedule_; | 571 Schedule* schedule_; |
| 531 MachineOperatorBuilder machine_; | 572 MachineOperatorBuilder machine_; |
| 532 CommonOperatorBuilder common_; | 573 CommonOperatorBuilder common_; |
| 533 CallDescriptor* call_descriptor_; | 574 CallDescriptor* call_descriptor_; |
| 534 Node** parameters_; | 575 Node** parameters_; |
| 535 BasicBlock* current_block_; | 576 BasicBlock* current_block_; |
| 536 | 577 |
| 537 DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler); | 578 DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler); |
| 538 }; | 579 }; |
| 539 | 580 |
| 540 } // namespace compiler | 581 } // namespace compiler |
| 541 } // namespace internal | 582 } // namespace internal |
| 542 } // namespace v8 | 583 } // namespace v8 |
| 543 | 584 |
| 544 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 585 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
| OLD | NEW |