| 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/assembler.h" |
| 8 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
| 9 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| 10 #include "src/compiler/linkage.h" | 11 #include "src/compiler/linkage.h" |
| 11 #include "src/compiler/machine-operator.h" | 12 #include "src/compiler/machine-operator.h" |
| 12 #include "src/compiler/node.h" | 13 #include "src/compiler/node.h" |
| 13 #include "src/compiler/operator.h" | 14 #include "src/compiler/operator.h" |
| 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 // The RawMachineAssembler produces a low-level IR graph. All nodes are wired | 23 // The RawMachineAssembler produces a low-level IR graph. All nodes are wired |
| 24 // into a graph and also placed into a schedule immediately, hence subsequent | 24 // into a graph and also placed into a schedule immediately, hence subsequent |
| 25 // code generation can happen without the need for scheduling. | 25 // code generation can happen without the need for scheduling. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 Graph* graph() const { return graph_; } | 59 Graph* graph() const { return graph_; } |
| 60 Schedule* schedule() { return schedule_; } | 60 Schedule* schedule() { return schedule_; } |
| 61 Zone* zone() const { return graph()->zone(); } | 61 Zone* zone() const { return graph()->zone(); } |
| 62 MachineOperatorBuilder* machine() { return &machine_; } | 62 MachineOperatorBuilder* machine() { return &machine_; } |
| 63 CommonOperatorBuilder* common() { return &common_; } | 63 CommonOperatorBuilder* common() { return &common_; } |
| 64 CallDescriptor* call_descriptor() const { return call_descriptor_; } | 64 CallDescriptor* call_descriptor() const { return call_descriptor_; } |
| 65 size_t parameter_count() const { return machine_sig()->parameter_count(); } | 65 size_t parameter_count() const { return machine_sig()->parameter_count(); } |
| 66 const MachineSignature* machine_sig() const { | 66 const MachineSignature* machine_sig() const { |
| 67 return call_descriptor_->GetMachineSignature(); | 67 return call_descriptor_->GetMachineSignature(); |
| 68 } | 68 } |
| 69 BasicBlock* CurrentBlock(); |
| 69 | 70 |
| 70 // Finalizes the schedule and exports it to be used for code generation. Note | 71 // Finalizes the schedule and exports it to be used for code generation. Note |
| 71 // that this RawMachineAssembler becomes invalid after export. | 72 // that this RawMachineAssembler becomes invalid after export. |
| 72 Schedule* Export(); | 73 Schedule* Export(); |
| 73 | 74 |
| 74 // =========================================================================== | 75 // =========================================================================== |
| 75 // The following utility methods create new nodes with specific operators and | 76 // The following utility methods create new nodes with specific operators and |
| 76 // place them into the current basic block. They don't perform control flow, | 77 // place them into the current basic block. They don't perform control flow, |
| 77 // hence will not switch the current basic block. | 78 // hence will not switch the current basic block. |
| 78 | 79 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 120 } |
| 120 | 121 |
| 121 // Memory Operations. | 122 // Memory Operations. |
| 122 Node* Load(MachineType rep, Node* base) { | 123 Node* Load(MachineType rep, Node* base) { |
| 123 return Load(rep, base, IntPtrConstant(0)); | 124 return Load(rep, base, IntPtrConstant(0)); |
| 124 } | 125 } |
| 125 Node* Load(MachineType rep, Node* base, Node* index) { | 126 Node* Load(MachineType rep, Node* base, Node* index) { |
| 126 return NewNode(machine()->Load(rep), base, index, graph()->start(), | 127 return NewNode(machine()->Load(rep), base, index, graph()->start(), |
| 127 graph()->start()); | 128 graph()->start()); |
| 128 } | 129 } |
| 129 void Store(MachineType rep, Node* base, Node* value) { | 130 Node* Store(MachineType rep, Node* base, Node* value) { |
| 130 Store(rep, base, IntPtrConstant(0), value); | 131 return Store(rep, base, IntPtrConstant(0), value); |
| 131 } | 132 } |
| 132 void Store(MachineType rep, Node* base, Node* index, Node* value) { | 133 Node* Store(MachineType rep, Node* base, Node* index, Node* value) { |
| 133 NewNode(machine()->Store(StoreRepresentation(rep, kNoWriteBarrier)), base, | 134 return NewNode(machine()->Store(StoreRepresentation(rep, kNoWriteBarrier)), |
| 134 index, value, graph()->start(), graph()->start()); | 135 base, index, value, graph()->start(), graph()->start()); |
| 135 } | 136 } |
| 136 | 137 |
| 137 // Arithmetic Operations. | 138 // Arithmetic Operations. |
| 138 Node* WordAnd(Node* a, Node* b) { | 139 Node* WordAnd(Node* a, Node* b) { |
| 139 return NewNode(machine()->WordAnd(), a, b); | 140 return NewNode(machine()->WordAnd(), a, b); |
| 140 } | 141 } |
| 141 Node* WordOr(Node* a, Node* b) { return NewNode(machine()->WordOr(), a, b); } | 142 Node* WordOr(Node* a, Node* b) { return NewNode(machine()->WordOr(), a, b); } |
| 142 Node* WordXor(Node* a, Node* b) { | 143 Node* WordXor(Node* a, Node* b) { |
| 143 return NewNode(machine()->WordXor(), a, b); | 144 return NewNode(machine()->WordXor(), a, b); |
| 144 } | 145 } |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 Node* LoadStackPointer() { return NewNode(machine()->LoadStackPointer()); } | 468 Node* LoadStackPointer() { return NewNode(machine()->LoadStackPointer()); } |
| 468 Node* LoadFramePointer() { return NewNode(machine()->LoadFramePointer()); } | 469 Node* LoadFramePointer() { return NewNode(machine()->LoadFramePointer()); } |
| 469 | 470 |
| 470 // Parameters. | 471 // Parameters. |
| 471 Node* Parameter(size_t index); | 472 Node* Parameter(size_t index); |
| 472 | 473 |
| 473 // Pointer utilities. | 474 // Pointer utilities. |
| 474 Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) { | 475 Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) { |
| 475 return Load(rep, PointerConstant(address), Int32Constant(offset)); | 476 return Load(rep, PointerConstant(address), Int32Constant(offset)); |
| 476 } | 477 } |
| 477 void StoreToPointer(void* address, MachineType rep, Node* node) { | 478 Node* StoreToPointer(void* address, MachineType rep, Node* node) { |
| 478 Store(rep, PointerConstant(address), node); | 479 return Store(rep, PointerConstant(address), node); |
| 479 } | 480 } |
| 480 Node* StringConstant(const char* string) { | 481 Node* StringConstant(const char* string) { |
| 481 return HeapConstant(isolate()->factory()->InternalizeUtf8String(string)); | 482 return HeapConstant(isolate()->factory()->InternalizeUtf8String(string)); |
| 482 } | 483 } |
| 483 | 484 |
| 484 // Call through CallFunctionStub with lazy deopt and frame-state. | 485 // Call through CallFunctionStub with lazy deopt and frame-state. |
| 485 Node* CallFunctionStub0(Node* function, Node* receiver, Node* context, | 486 Node* CallFunctionStub0(Node* function, Node* receiver, Node* context, |
| 486 Node* frame_state, CallFunctionFlags flags); | 487 Node* frame_state, CallFunctionFlags flags); |
| 487 // Call to a JS function with zero parameters. | 488 // Call to a JS function with zero parameters. |
| 488 Node* CallJS0(Node* function, Node* receiver, Node* context, | 489 Node* CallJS0(Node* function, Node* receiver, Node* context, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 | 573 |
| 573 Node* NewNode(const Operator* op, int value_input_count, | 574 Node* NewNode(const Operator* op, int value_input_count, |
| 574 Node** value_inputs) { | 575 Node** value_inputs) { |
| 575 return MakeNode(op, value_input_count, value_inputs); | 576 return MakeNode(op, value_input_count, value_inputs); |
| 576 } | 577 } |
| 577 | 578 |
| 578 private: | 579 private: |
| 579 Node* MakeNode(const Operator* op, int input_count, Node** inputs); | 580 Node* MakeNode(const Operator* op, int input_count, Node** inputs); |
| 580 BasicBlock* Use(Label* label); | 581 BasicBlock* Use(Label* label); |
| 581 BasicBlock* EnsureBlock(Label* label); | 582 BasicBlock* EnsureBlock(Label* label); |
| 582 BasicBlock* CurrentBlock(); | |
| 583 | 583 |
| 584 Isolate* isolate_; | 584 Isolate* isolate_; |
| 585 Graph* graph_; | 585 Graph* graph_; |
| 586 Schedule* schedule_; | 586 Schedule* schedule_; |
| 587 MachineOperatorBuilder machine_; | 587 MachineOperatorBuilder machine_; |
| 588 CommonOperatorBuilder common_; | 588 CommonOperatorBuilder common_; |
| 589 CallDescriptor* call_descriptor_; | 589 CallDescriptor* call_descriptor_; |
| 590 Node** parameters_; | 590 Node** parameters_; |
| 591 BasicBlock* current_block_; | 591 BasicBlock* current_block_; |
| 592 | 592 |
| 593 DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler); | 593 DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler); |
| 594 }; | 594 }; |
| 595 | 595 |
| 596 } // namespace compiler | 596 } // namespace compiler |
| 597 } // namespace internal | 597 } // namespace internal |
| 598 } // namespace v8 | 598 } // namespace v8 |
| 599 | 599 |
| 600 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 600 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
| OLD | NEW |