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

Side by Side Diff: src/compiler/raw-machine-assembler.h

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/pipeline.cc ('k') | src/compiler/raw-machine-assembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_
6 #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_
7
8 #include "src/v8.h"
9
10 #include "src/compiler/common-operator.h"
11 #include "src/compiler/graph-builder.h"
12 #include "src/compiler/machine-node-factory.h"
13 #include "src/compiler/machine-operator.h"
14 #include "src/compiler/node.h"
15 #include "src/compiler/operator.h"
16
17
18 namespace v8 {
19 namespace internal {
20 namespace compiler {
21
22 class BasicBlock;
23 class Schedule;
24
25
26 class RawMachineAssembler : public GraphBuilder,
27 public MachineNodeFactory<RawMachineAssembler> {
28 public:
29 class Label {
30 public:
31 Label() : block_(NULL), used_(false), bound_(false) {}
32 ~Label() { ASSERT(bound_ || !used_); }
33
34 BasicBlock* block() { return block_; }
35
36 private:
37 // Private constructor for exit label.
38 explicit Label(BasicBlock* block)
39 : block_(block), used_(false), bound_(false) {}
40
41 BasicBlock* block_;
42 bool used_;
43 bool bound_;
44 friend class RawMachineAssembler;
45 DISALLOW_COPY_AND_ASSIGN(Label);
46 };
47
48 RawMachineAssembler(
49 Graph* graph, MachineCallDescriptorBuilder* call_descriptor_builder,
50 MachineRepresentation word = MachineOperatorBuilder::pointer_rep());
51 virtual ~RawMachineAssembler() {}
52
53 Isolate* isolate() const { return zone()->isolate(); }
54 Zone* zone() const { return graph()->zone(); }
55 MachineOperatorBuilder* machine() { return &machine_; }
56 CommonOperatorBuilder* common() { return &common_; }
57 CallDescriptor* call_descriptor() const {
58 return call_descriptor_builder_->BuildCallDescriptor(zone());
59 }
60 int parameter_count() const {
61 return call_descriptor_builder_->parameter_count();
62 }
63 const MachineRepresentation* parameter_types() const {
64 return call_descriptor_builder_->parameter_types();
65 }
66
67 // Parameters.
68 Node* Parameter(int index);
69
70 // Control flow.
71 Label* Exit();
72 void Goto(Label* label);
73 void Branch(Node* condition, Label* true_val, Label* false_val);
74 // Call to a JS function with zero parameters.
75 Node* CallJS0(Node* function, Node* receiver, Label* continuation,
76 Label* deoptimization);
77 // Call to a runtime function with zero parameters.
78 Node* CallRuntime1(Runtime::FunctionId function, Node* arg0,
79 Label* continuation, Label* deoptimization);
80 void Return(Node* value);
81 void Bind(Label* label);
82 void Deoptimize(Node* state);
83
84 // Variables.
85 Node* Phi(Node* n1, Node* n2) { return NewNode(common()->Phi(2), n1, n2); }
86 Node* Phi(Node* n1, Node* n2, Node* n3) {
87 return NewNode(common()->Phi(3), n1, n2, n3);
88 }
89 Node* Phi(Node* n1, Node* n2, Node* n3, Node* n4) {
90 return NewNode(common()->Phi(4), n1, n2, n3, n4);
91 }
92
93 // MachineAssembler is invalid after export.
94 Schedule* Export();
95
96 protected:
97 virtual Node* MakeNode(Operator* op, int input_count, Node** inputs);
98
99 Schedule* schedule() {
100 ASSERT(ScheduleValid());
101 return schedule_;
102 }
103
104 private:
105 bool ScheduleValid() { return schedule_ != NULL; }
106
107 BasicBlock* Use(Label* label);
108 BasicBlock* EnsureBlock(Label* label);
109 BasicBlock* CurrentBlock();
110
111 typedef std::vector<MachineRepresentation,
112 zone_allocator<MachineRepresentation> >
113 RepresentationVector;
114
115 Schedule* schedule_;
116 MachineOperatorBuilder machine_;
117 CommonOperatorBuilder common_;
118 MachineCallDescriptorBuilder* call_descriptor_builder_;
119 Node** parameters_;
120 Label exit_label_;
121 BasicBlock* current_block_;
122
123 DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler);
124 };
125
126 } // namespace compiler
127 } // namespace internal
128 } // namespace v8
129
130 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_
OLDNEW
« no previous file with comments | « src/compiler/pipeline.cc ('k') | src/compiler/raw-machine-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698