OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_COMMON_OPERATOR_H_ | 5 #ifndef V8_COMPILER_COMMON_OPERATOR_H_ |
6 #define V8_COMPILER_COMMON_OPERATOR_H_ | 6 #define V8_COMPILER_COMMON_OPERATOR_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/machine-type.h" | 10 #include "src/compiler/machine-type.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // including JavaScript, mid-level, and low-level. | 74 // including JavaScript, mid-level, and low-level. |
75 // TODO(titzer): Move the mnemonics into SimpleOperator and Operator1 classes. | 75 // TODO(titzer): Move the mnemonics into SimpleOperator and Operator1 classes. |
76 class CommonOperatorBuilder { | 76 class CommonOperatorBuilder { |
77 public: | 77 public: |
78 explicit CommonOperatorBuilder(Zone* zone) : zone_(zone) {} | 78 explicit CommonOperatorBuilder(Zone* zone) : zone_(zone) {} |
79 | 79 |
80 #define CONTROL_OP(name, inputs, controls) \ | 80 #define CONTROL_OP(name, inputs, controls) \ |
81 return new (zone_) ControlOperator(IrOpcode::k##name, Operator::kFoldable, \ | 81 return new (zone_) ControlOperator(IrOpcode::k##name, Operator::kFoldable, \ |
82 inputs, 0, controls, #name); | 82 inputs, 0, controls, #name); |
83 | 83 |
84 Operator* Start(int num_formal_parameters) { | 84 const Operator* Start(int num_formal_parameters) { |
85 // Outputs are formal parameters, plus context, receiver, and JSFunction. | 85 // Outputs are formal parameters, plus context, receiver, and JSFunction. |
86 int outputs = num_formal_parameters + 3; | 86 int outputs = num_formal_parameters + 3; |
87 return new (zone_) ControlOperator(IrOpcode::kStart, Operator::kFoldable, 0, | 87 return new (zone_) ControlOperator(IrOpcode::kStart, Operator::kFoldable, 0, |
88 outputs, 0, "Start"); | 88 outputs, 0, "Start"); |
89 } | 89 } |
90 Operator* Dead() { CONTROL_OP(Dead, 0, 0); } | 90 const Operator* Dead() { CONTROL_OP(Dead, 0, 0); } |
91 Operator* End() { CONTROL_OP(End, 0, 1); } | 91 const Operator* End() { CONTROL_OP(End, 0, 1); } |
92 Operator* Branch() { CONTROL_OP(Branch, 1, 1); } | 92 const Operator* Branch() { CONTROL_OP(Branch, 1, 1); } |
93 Operator* IfTrue() { CONTROL_OP(IfTrue, 0, 1); } | 93 const Operator* IfTrue() { CONTROL_OP(IfTrue, 0, 1); } |
94 Operator* IfFalse() { CONTROL_OP(IfFalse, 0, 1); } | 94 const Operator* IfFalse() { CONTROL_OP(IfFalse, 0, 1); } |
95 Operator* Throw() { CONTROL_OP(Throw, 1, 1); } | 95 const Operator* Throw() { CONTROL_OP(Throw, 1, 1); } |
96 | 96 |
97 Operator* Return() { | 97 const Operator* Return() { |
98 return new (zone_) ControlOperator( | 98 return new (zone_) ControlOperator( |
99 IrOpcode::kReturn, Operator::kNoProperties, 1, 0, 1, "Return"); | 99 IrOpcode::kReturn, Operator::kNoProperties, 1, 0, 1, "Return"); |
100 } | 100 } |
101 | 101 |
102 Operator* Merge(int controls) { | 102 const Operator* Merge(int controls) { |
103 return new (zone_) ControlOperator(IrOpcode::kMerge, Operator::kFoldable, 0, | 103 return new (zone_) ControlOperator(IrOpcode::kMerge, Operator::kFoldable, 0, |
104 0, controls, "Merge"); | 104 0, controls, "Merge"); |
105 } | 105 } |
106 | 106 |
107 Operator* Loop(int controls) { | 107 const Operator* Loop(int controls) { |
108 return new (zone_) ControlOperator(IrOpcode::kLoop, Operator::kFoldable, 0, | 108 return new (zone_) ControlOperator(IrOpcode::kLoop, Operator::kFoldable, 0, |
109 0, controls, "Loop"); | 109 0, controls, "Loop"); |
110 } | 110 } |
111 | 111 |
112 Operator* Parameter(int index) { | 112 const Operator* Parameter(int index) { |
113 return new (zone_) Operator1<int>(IrOpcode::kParameter, Operator::kPure, 1, | 113 return new (zone_) Operator1<int>(IrOpcode::kParameter, Operator::kPure, 1, |
114 1, "Parameter", index); | 114 1, "Parameter", index); |
115 } | 115 } |
116 Operator* Int32Constant(int32_t value) { | 116 const Operator* Int32Constant(int32_t value) { |
117 return new (zone_) | 117 return new (zone_) |
118 Operator1<int32_t>(IrOpcode::kInt32Constant, Operator::kPure, 0, 1, | 118 Operator1<int32_t>(IrOpcode::kInt32Constant, Operator::kPure, 0, 1, |
119 "Int32Constant", value); | 119 "Int32Constant", value); |
120 } | 120 } |
121 Operator* Int64Constant(int64_t value) { | 121 const Operator* Int64Constant(int64_t value) { |
122 return new (zone_) | 122 return new (zone_) |
123 Operator1<int64_t>(IrOpcode::kInt64Constant, Operator::kPure, 0, 1, | 123 Operator1<int64_t>(IrOpcode::kInt64Constant, Operator::kPure, 0, 1, |
124 "Int64Constant", value); | 124 "Int64Constant", value); |
125 } | 125 } |
126 Operator* Float64Constant(double value) { | 126 const Operator* Float64Constant(double value) { |
127 return new (zone_) | 127 return new (zone_) |
128 Operator1<double>(IrOpcode::kFloat64Constant, Operator::kPure, 0, 1, | 128 Operator1<double>(IrOpcode::kFloat64Constant, Operator::kPure, 0, 1, |
129 "Float64Constant", value); | 129 "Float64Constant", value); |
130 } | 130 } |
131 Operator* ExternalConstant(ExternalReference value) { | 131 const Operator* ExternalConstant(ExternalReference value) { |
132 return new (zone_) Operator1<ExternalReference>(IrOpcode::kExternalConstant, | 132 return new (zone_) Operator1<ExternalReference>(IrOpcode::kExternalConstant, |
133 Operator::kPure, 0, 1, | 133 Operator::kPure, 0, 1, |
134 "ExternalConstant", value); | 134 "ExternalConstant", value); |
135 } | 135 } |
136 Operator* NumberConstant(double value) { | 136 const Operator* NumberConstant(double value) { |
137 return new (zone_) | 137 return new (zone_) |
138 Operator1<double>(IrOpcode::kNumberConstant, Operator::kPure, 0, 1, | 138 Operator1<double>(IrOpcode::kNumberConstant, Operator::kPure, 0, 1, |
139 "NumberConstant", value); | 139 "NumberConstant", value); |
140 } | 140 } |
141 Operator* HeapConstant(Unique<Object> value) { | 141 const Operator* HeapConstant(Unique<Object> value) { |
142 return new (zone_) Operator1<Unique<Object> >( | 142 return new (zone_) Operator1<Unique<Object> >( |
143 IrOpcode::kHeapConstant, Operator::kPure, 0, 1, "HeapConstant", value); | 143 IrOpcode::kHeapConstant, Operator::kPure, 0, 1, "HeapConstant", value); |
144 } | 144 } |
145 Operator* Phi(MachineType type, int arguments) { | 145 const Operator* Phi(MachineType type, int arguments) { |
146 DCHECK(arguments > 0); // Disallow empty phis. | 146 DCHECK(arguments > 0); // Disallow empty phis. |
147 return new (zone_) Operator1<MachineType>(IrOpcode::kPhi, Operator::kPure, | 147 return new (zone_) Operator1<MachineType>(IrOpcode::kPhi, Operator::kPure, |
148 arguments, 1, "Phi", type); | 148 arguments, 1, "Phi", type); |
149 } | 149 } |
150 Operator* EffectPhi(int arguments) { | 150 const Operator* EffectPhi(int arguments) { |
151 DCHECK(arguments > 0); // Disallow empty phis. | 151 DCHECK(arguments > 0); // Disallow empty phis. |
152 return new (zone_) Operator1<int>(IrOpcode::kEffectPhi, Operator::kPure, 0, | 152 return new (zone_) Operator1<int>(IrOpcode::kEffectPhi, Operator::kPure, 0, |
153 0, "EffectPhi", arguments); | 153 0, "EffectPhi", arguments); |
154 } | 154 } |
155 Operator* ControlEffect() { | 155 const Operator* ControlEffect() { |
156 return new (zone_) SimpleOperator(IrOpcode::kControlEffect, Operator::kPure, | 156 return new (zone_) SimpleOperator(IrOpcode::kControlEffect, Operator::kPure, |
157 0, 0, "ControlEffect"); | 157 0, 0, "ControlEffect"); |
158 } | 158 } |
159 Operator* ValueEffect(int arguments) { | 159 const Operator* ValueEffect(int arguments) { |
160 DCHECK(arguments > 0); // Disallow empty value effects. | 160 DCHECK(arguments > 0); // Disallow empty value effects. |
161 return new (zone_) SimpleOperator(IrOpcode::kValueEffect, Operator::kPure, | 161 return new (zone_) SimpleOperator(IrOpcode::kValueEffect, Operator::kPure, |
162 arguments, 0, "ValueEffect"); | 162 arguments, 0, "ValueEffect"); |
163 } | 163 } |
164 Operator* Finish(int arguments) { | 164 const Operator* Finish(int arguments) { |
165 DCHECK(arguments > 0); // Disallow empty finishes. | 165 DCHECK(arguments > 0); // Disallow empty finishes. |
166 return new (zone_) Operator1<int>(IrOpcode::kFinish, Operator::kPure, 1, 1, | 166 return new (zone_) Operator1<int>(IrOpcode::kFinish, Operator::kPure, 1, 1, |
167 "Finish", arguments); | 167 "Finish", arguments); |
168 } | 168 } |
169 Operator* StateValues(int arguments) { | 169 const Operator* StateValues(int arguments) { |
170 return new (zone_) Operator1<int>(IrOpcode::kStateValues, Operator::kPure, | 170 return new (zone_) Operator1<int>(IrOpcode::kStateValues, Operator::kPure, |
171 arguments, 1, "StateValues", arguments); | 171 arguments, 1, "StateValues", arguments); |
172 } | 172 } |
173 Operator* FrameState(BailoutId bailout_id, OutputFrameStateCombine combine) { | 173 const Operator* FrameState(BailoutId bailout_id, |
| 174 OutputFrameStateCombine combine) { |
174 return new (zone_) Operator1<FrameStateCallInfo>( | 175 return new (zone_) Operator1<FrameStateCallInfo>( |
175 IrOpcode::kFrameState, Operator::kPure, 4, 1, "FrameState", | 176 IrOpcode::kFrameState, Operator::kPure, 4, 1, "FrameState", |
176 FrameStateCallInfo(bailout_id, combine)); | 177 FrameStateCallInfo(bailout_id, combine)); |
177 } | 178 } |
178 Operator* Call(CallDescriptor* descriptor) { | 179 const Operator* Call(CallDescriptor* descriptor) { |
179 return new (zone_) CallOperator(descriptor, "Call"); | 180 return new (zone_) CallOperator(descriptor, "Call"); |
180 } | 181 } |
181 Operator* Projection(size_t index) { | 182 const Operator* Projection(size_t index) { |
182 return new (zone_) Operator1<size_t>(IrOpcode::kProjection, Operator::kPure, | 183 return new (zone_) Operator1<size_t>(IrOpcode::kProjection, Operator::kPure, |
183 1, 1, "Projection", index); | 184 1, 1, "Projection", index); |
184 } | 185 } |
185 | 186 |
186 private: | 187 private: |
187 Zone* zone_; | 188 Zone* zone_; |
188 }; | 189 }; |
189 | 190 |
190 } // namespace compiler | 191 } // namespace compiler |
191 } // namespace internal | 192 } // namespace internal |
192 } // namespace v8 | 193 } // namespace v8 |
193 | 194 |
194 #endif // V8_COMPILER_COMMON_OPERATOR_H_ | 195 #endif // V8_COMPILER_COMMON_OPERATOR_H_ |
OLD | NEW |