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/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
11 #include "src/compiler/graph-builder.h" | 11 #include "src/compiler/graph.h" |
12 #include "src/compiler/linkage.h" | 12 #include "src/compiler/linkage.h" |
13 #include "src/compiler/machine-operator.h" | 13 #include "src/compiler/machine-operator.h" |
14 #include "src/compiler/node.h" | 14 #include "src/compiler/node.h" |
15 #include "src/compiler/operator.h" | 15 #include "src/compiler/operator.h" |
16 | 16 #include "test/cctest/compiler/graph-builder.h" |
17 | 17 |
18 namespace v8 { | 18 namespace v8 { |
19 namespace internal { | 19 namespace internal { |
20 namespace compiler { | 20 namespace compiler { |
21 | 21 |
22 class BasicBlock; | 22 class BasicBlock; |
23 class Schedule; | 23 class Schedule; |
24 | 24 |
25 | |
26 class RawMachineAssembler : public GraphBuilder { | 25 class RawMachineAssembler : public GraphBuilder { |
27 public: | 26 public: |
28 class Label { | 27 class Label { |
29 public: | 28 public: |
30 Label() : block_(NULL), used_(false), bound_(false) {} | 29 Label() : block_(NULL), used_(false), bound_(false) {} |
31 ~Label() { DCHECK(bound_ || !used_); } | 30 ~Label() { DCHECK(bound_ || !used_); } |
32 | 31 |
33 BasicBlock* block() { return block_; } | 32 BasicBlock* block() { return block_; } |
34 | 33 |
35 private: | 34 private: |
36 // Private constructor for exit label. | 35 // Private constructor for exit label. |
37 explicit Label(BasicBlock* block) | 36 explicit Label(BasicBlock* block) |
38 : block_(block), used_(false), bound_(false) {} | 37 : block_(block), used_(false), bound_(false) {} |
39 | 38 |
40 BasicBlock* block_; | 39 BasicBlock* block_; |
41 bool used_; | 40 bool used_; |
42 bool bound_; | 41 bool bound_; |
43 friend class RawMachineAssembler; | 42 friend class RawMachineAssembler; |
44 DISALLOW_COPY_AND_ASSIGN(Label); | 43 DISALLOW_COPY_AND_ASSIGN(Label); |
45 }; | 44 }; |
46 | 45 |
47 RawMachineAssembler(Isolate* isolate, Graph* graph, | 46 RawMachineAssembler(Isolate* isolate, Graph* graph, |
48 MachineSignature* machine_sig, | 47 MachineSignature* machine_sig, |
49 MachineType word = kMachPtr, | 48 MachineType word = kMachPtr, |
50 MachineOperatorBuilder::Flags flags = | 49 MachineOperatorBuilder::Flags flags = |
51 MachineOperatorBuilder::Flag::kNoFlags); | 50 MachineOperatorBuilder::Flag::kNoFlags); |
52 ~RawMachineAssembler() OVERRIDE {} | 51 ~RawMachineAssembler() {} |
53 | 52 |
54 Zone* zone() const { return graph()->zone(); } | 53 Zone* zone() const { return graph()->zone(); } |
55 MachineOperatorBuilder* machine() { return &machine_; } | 54 MachineOperatorBuilder* machine() { return &machine_; } |
56 CommonOperatorBuilder* common() { return &common_; } | 55 CommonOperatorBuilder* common() { return &common_; } |
57 CallDescriptor* call_descriptor() const { return call_descriptor_; } | 56 CallDescriptor* call_descriptor() const { return call_descriptor_; } |
58 size_t parameter_count() const { return machine_sig_->parameter_count(); } | 57 size_t parameter_count() const { return machine_sig_->parameter_count(); } |
59 MachineSignature* machine_sig() const { return machine_sig_; } | 58 MachineSignature* machine_sig() const { return machine_sig_; } |
60 | 59 |
61 Node* UndefinedConstant() { | 60 Node* UndefinedConstant() { |
62 Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable( | 61 Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable( |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 return NewNode(common()->Phi(type, 3), n1, n2, n3); | 422 return NewNode(common()->Phi(type, 3), n1, n2, n3); |
424 } | 423 } |
425 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3, Node* n4) { | 424 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3, Node* n4) { |
426 return NewNode(common()->Phi(type, 4), n1, n2, n3, n4); | 425 return NewNode(common()->Phi(type, 4), n1, n2, n3, n4); |
427 } | 426 } |
428 | 427 |
429 // MachineAssembler is invalid after export. | 428 // MachineAssembler is invalid after export. |
430 Schedule* Export(); | 429 Schedule* Export(); |
431 | 430 |
432 protected: | 431 protected: |
433 Node* MakeNode(const Operator* op, int input_count, Node** inputs, | 432 virtual Node* MakeNode(const Operator* op, int value_input_count, |
434 bool incomplete) FINAL; | 433 Node** value_inputs, bool incomplete) FINAL; |
435 | 434 |
436 bool ScheduleValid() { return schedule_ != NULL; } | 435 bool ScheduleValid() { return schedule_ != NULL; } |
437 | 436 |
438 Schedule* schedule() { | 437 Schedule* schedule() { |
439 DCHECK(ScheduleValid()); | 438 DCHECK(ScheduleValid()); |
440 return schedule_; | 439 return schedule_; |
441 } | 440 } |
442 | 441 |
443 private: | 442 private: |
444 BasicBlock* Use(Label* label); | 443 BasicBlock* Use(Label* label); |
445 BasicBlock* EnsureBlock(Label* label); | 444 BasicBlock* EnsureBlock(Label* label); |
446 BasicBlock* CurrentBlock(); | 445 BasicBlock* CurrentBlock(); |
447 | 446 |
| 447 Isolate* isolate_; |
| 448 Graph* graph_; |
448 Schedule* schedule_; | 449 Schedule* schedule_; |
449 MachineOperatorBuilder machine_; | 450 MachineOperatorBuilder machine_; |
450 CommonOperatorBuilder common_; | 451 CommonOperatorBuilder common_; |
451 MachineSignature* machine_sig_; | 452 MachineSignature* machine_sig_; |
452 CallDescriptor* call_descriptor_; | 453 CallDescriptor* call_descriptor_; |
453 Node** parameters_; | 454 Node** parameters_; |
454 Label exit_label_; | 455 Label exit_label_; |
455 BasicBlock* current_block_; | 456 BasicBlock* current_block_; |
456 | 457 |
457 DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler); | 458 DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler); |
458 }; | 459 }; |
459 | 460 |
460 } // namespace compiler | 461 } // namespace compiler |
461 } // namespace internal | 462 } // namespace internal |
462 } // namespace v8 | 463 } // namespace v8 |
463 | 464 |
464 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 465 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
OLD | NEW |