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

Side by Side Diff: test/unittests/compiler/common-operator-unittest.cc

Issue 686213002: Inline trivial OperatorProperties methods. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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
OLDNEW
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 #include "src/compiler/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/compiler/operator-properties-inl.h" 9 #include "src/compiler/operator-properties-inl.h"
10 #include "test/unittests/test-utils.h" 10 #include "test/unittests/test-utils.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 CommonOperatorBuilder common2(zone()); 68 CommonOperatorBuilder common2(zone());
69 EXPECT_EQ((common1.*sop.constructor)(), (common2.*sop.constructor)()); 69 EXPECT_EQ((common1.*sop.constructor)(), (common2.*sop.constructor)());
70 } 70 }
71 71
72 72
73 TEST_P(CommonSharedOperatorTest, NumberOfInputsAndOutputs) { 73 TEST_P(CommonSharedOperatorTest, NumberOfInputsAndOutputs) {
74 CommonOperatorBuilder common(zone()); 74 CommonOperatorBuilder common(zone());
75 const SharedOperator& sop = GetParam(); 75 const SharedOperator& sop = GetParam();
76 const Operator* op = (common.*sop.constructor)(); 76 const Operator* op = (common.*sop.constructor)();
77 77
78 EXPECT_EQ(sop.value_input_count, OperatorProperties::GetValueInputCount(op)); 78 EXPECT_EQ(sop.value_input_count, op->ValueInputCount());
79 EXPECT_EQ(sop.effect_input_count, 79 EXPECT_EQ(sop.effect_input_count, op->EffectInputCount());
80 OperatorProperties::GetEffectInputCount(op)); 80 EXPECT_EQ(sop.control_input_count, op->ControlInputCount());
81 EXPECT_EQ(sop.control_input_count,
82 OperatorProperties::GetControlInputCount(op));
83 EXPECT_EQ( 81 EXPECT_EQ(
84 sop.value_input_count + sop.effect_input_count + sop.control_input_count, 82 sop.value_input_count + sop.effect_input_count + sop.control_input_count,
85 OperatorProperties::GetTotalInputCount(op)); 83 OperatorProperties::GetTotalInputCount(op));
86 84
87 EXPECT_EQ(0, OperatorProperties::GetValueOutputCount(op)); 85 EXPECT_EQ(0, op->ValueOutputCount());
88 EXPECT_EQ(sop.effect_output_count, 86 EXPECT_EQ(sop.effect_output_count, op->EffectOutputCount());
89 OperatorProperties::GetEffectOutputCount(op)); 87 EXPECT_EQ(sop.control_output_count, op->ControlOutputCount());
90 EXPECT_EQ(sop.control_output_count,
91 OperatorProperties::GetControlOutputCount(op));
92 } 88 }
93 89
94 90
95 TEST_P(CommonSharedOperatorTest, OpcodeIsCorrect) { 91 TEST_P(CommonSharedOperatorTest, OpcodeIsCorrect) {
96 CommonOperatorBuilder common(zone()); 92 CommonOperatorBuilder common(zone());
97 const SharedOperator& sop = GetParam(); 93 const SharedOperator& sop = GetParam();
98 const Operator* op = (common.*sop.constructor)(); 94 const Operator* op = (common.*sop.constructor)();
99 EXPECT_EQ(sop.opcode, op->opcode()); 95 EXPECT_EQ(sop.opcode, op->opcode());
100 } 96 }
101 97
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 158
163 } // namespace 159 } // namespace
164 160
165 161
166 TEST_F(CommonOperatorTest, Branch) { 162 TEST_F(CommonOperatorTest, Branch) {
167 TRACED_FOREACH(BranchHint, hint, kHints) { 163 TRACED_FOREACH(BranchHint, hint, kHints) {
168 const Operator* const op = common()->Branch(hint); 164 const Operator* const op = common()->Branch(hint);
169 EXPECT_EQ(IrOpcode::kBranch, op->opcode()); 165 EXPECT_EQ(IrOpcode::kBranch, op->opcode());
170 EXPECT_EQ(Operator::kFoldable, op->properties()); 166 EXPECT_EQ(Operator::kFoldable, op->properties());
171 EXPECT_EQ(hint, BranchHintOf(op)); 167 EXPECT_EQ(hint, BranchHintOf(op));
172 EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); 168 EXPECT_EQ(1, op->ValueInputCount());
173 EXPECT_EQ(0, OperatorProperties::GetEffectInputCount(op)); 169 EXPECT_EQ(0, op->EffectInputCount());
174 EXPECT_EQ(1, OperatorProperties::GetControlInputCount(op)); 170 EXPECT_EQ(1, op->ControlInputCount());
175 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op)); 171 EXPECT_EQ(2, OperatorProperties::GetTotalInputCount(op));
176 EXPECT_EQ(0, OperatorProperties::GetValueOutputCount(op)); 172 EXPECT_EQ(0, op->ValueOutputCount());
177 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); 173 EXPECT_EQ(0, op->EffectOutputCount());
178 EXPECT_EQ(2, OperatorProperties::GetControlOutputCount(op)); 174 EXPECT_EQ(2, op->ControlOutputCount());
179 } 175 }
180 } 176 }
181 177
182 178
183 TEST_F(CommonOperatorTest, Select) { 179 TEST_F(CommonOperatorTest, Select) {
184 static const MachineType kTypes[] = { 180 static const MachineType kTypes[] = {
185 kMachInt8, kMachUint8, kMachInt16, kMachUint16, 181 kMachInt8, kMachUint8, kMachInt16, kMachUint16,
186 kMachInt32, kMachUint32, kMachInt64, kMachUint64, 182 kMachInt32, kMachUint32, kMachInt64, kMachUint64,
187 kMachFloat32, kMachFloat64, kMachAnyTagged}; 183 kMachFloat32, kMachFloat64, kMachAnyTagged};
188 TRACED_FOREACH(MachineType, type, kTypes) { 184 TRACED_FOREACH(MachineType, type, kTypes) {
189 TRACED_FOREACH(BranchHint, hint, kHints) { 185 TRACED_FOREACH(BranchHint, hint, kHints) {
190 const Operator* const op = common()->Select(type, hint); 186 const Operator* const op = common()->Select(type, hint);
191 EXPECT_EQ(IrOpcode::kSelect, op->opcode()); 187 EXPECT_EQ(IrOpcode::kSelect, op->opcode());
192 EXPECT_EQ(Operator::kPure, op->properties()); 188 EXPECT_EQ(Operator::kPure, op->properties());
193 EXPECT_EQ(type, SelectParametersOf(op).type()); 189 EXPECT_EQ(type, SelectParametersOf(op).type());
194 EXPECT_EQ(hint, SelectParametersOf(op).hint()); 190 EXPECT_EQ(hint, SelectParametersOf(op).hint());
195 EXPECT_EQ(3, OperatorProperties::GetValueInputCount(op)); 191 EXPECT_EQ(3, op->ValueInputCount());
196 EXPECT_EQ(0, OperatorProperties::GetEffectInputCount(op)); 192 EXPECT_EQ(0, op->EffectInputCount());
197 EXPECT_EQ(0, OperatorProperties::GetControlInputCount(op)); 193 EXPECT_EQ(0, op->ControlInputCount());
198 EXPECT_EQ(3, OperatorProperties::GetTotalInputCount(op)); 194 EXPECT_EQ(3, OperatorProperties::GetTotalInputCount(op));
199 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); 195 EXPECT_EQ(1, op->ValueOutputCount());
200 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); 196 EXPECT_EQ(0, op->EffectOutputCount());
201 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); 197 EXPECT_EQ(0, op->ControlOutputCount());
202 } 198 }
203 } 199 }
204 } 200 }
205 201
206 202
207 TEST_F(CommonOperatorTest, Float32Constant) { 203 TEST_F(CommonOperatorTest, Float32Constant) {
208 TRACED_FOREACH(float, value, kFloatValues) { 204 TRACED_FOREACH(float, value, kFloatValues) {
209 const Operator* op = common()->Float32Constant(value); 205 const Operator* op = common()->Float32Constant(value);
210 EXPECT_PRED2(base::bit_equal_to<float>(), value, OpParameter<float>(op)); 206 EXPECT_PRED2(base::bit_equal_to<float>(), value, OpParameter<float>(op));
211 EXPECT_EQ(0, OperatorProperties::GetValueInputCount(op)); 207 EXPECT_EQ(0, op->ValueInputCount());
212 EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op)); 208 EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op));
213 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); 209 EXPECT_EQ(0, op->ControlOutputCount());
214 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); 210 EXPECT_EQ(0, op->EffectOutputCount());
215 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); 211 EXPECT_EQ(1, op->ValueOutputCount());
216 } 212 }
217 TRACED_FOREACH(float, v1, kFloatValues) { 213 TRACED_FOREACH(float, v1, kFloatValues) {
218 TRACED_FOREACH(float, v2, kFloatValues) { 214 TRACED_FOREACH(float, v2, kFloatValues) {
219 const Operator* op1 = common()->Float32Constant(v1); 215 const Operator* op1 = common()->Float32Constant(v1);
220 const Operator* op2 = common()->Float32Constant(v2); 216 const Operator* op2 = common()->Float32Constant(v2);
221 EXPECT_EQ(bit_cast<uint32_t>(v1) == bit_cast<uint32_t>(v2), 217 EXPECT_EQ(bit_cast<uint32_t>(v1) == bit_cast<uint32_t>(v2),
222 op1->Equals(op2)); 218 op1->Equals(op2));
223 } 219 }
224 } 220 }
225 } 221 }
226 222
227 223
228 TEST_F(CommonOperatorTest, Float64Constant) { 224 TEST_F(CommonOperatorTest, Float64Constant) {
229 TRACED_FOREACH(double, value, kFloatValues) { 225 TRACED_FOREACH(double, value, kFloatValues) {
230 const Operator* op = common()->Float64Constant(value); 226 const Operator* op = common()->Float64Constant(value);
231 EXPECT_PRED2(base::bit_equal_to<double>(), value, OpParameter<double>(op)); 227 EXPECT_PRED2(base::bit_equal_to<double>(), value, OpParameter<double>(op));
232 EXPECT_EQ(0, OperatorProperties::GetValueInputCount(op)); 228 EXPECT_EQ(0, op->ValueInputCount());
233 EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op)); 229 EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op));
234 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); 230 EXPECT_EQ(0, op->ControlOutputCount());
235 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); 231 EXPECT_EQ(0, op->EffectOutputCount());
236 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); 232 EXPECT_EQ(1, op->ValueOutputCount());
237 } 233 }
238 TRACED_FOREACH(double, v1, kFloatValues) { 234 TRACED_FOREACH(double, v1, kFloatValues) {
239 TRACED_FOREACH(double, v2, kFloatValues) { 235 TRACED_FOREACH(double, v2, kFloatValues) {
240 const Operator* op1 = common()->Float64Constant(v1); 236 const Operator* op1 = common()->Float64Constant(v1);
241 const Operator* op2 = common()->Float64Constant(v2); 237 const Operator* op2 = common()->Float64Constant(v2);
242 EXPECT_EQ(bit_cast<uint64_t>(v1) == bit_cast<uint64_t>(v2), 238 EXPECT_EQ(bit_cast<uint64_t>(v1) == bit_cast<uint64_t>(v2),
243 op1->Equals(op2)); 239 op1->Equals(op2));
244 } 240 }
245 } 241 }
246 } 242 }
247 243
248 244
249 TEST_F(CommonOperatorTest, NumberConstant) { 245 TEST_F(CommonOperatorTest, NumberConstant) {
250 TRACED_FOREACH(double, value, kFloatValues) { 246 TRACED_FOREACH(double, value, kFloatValues) {
251 const Operator* op = common()->NumberConstant(value); 247 const Operator* op = common()->NumberConstant(value);
252 EXPECT_PRED2(base::bit_equal_to<double>(), value, OpParameter<double>(op)); 248 EXPECT_PRED2(base::bit_equal_to<double>(), value, OpParameter<double>(op));
253 EXPECT_EQ(0, OperatorProperties::GetValueInputCount(op)); 249 EXPECT_EQ(0, op->ValueInputCount());
254 EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op)); 250 EXPECT_EQ(0, OperatorProperties::GetTotalInputCount(op));
255 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); 251 EXPECT_EQ(0, op->ControlOutputCount());
256 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); 252 EXPECT_EQ(0, op->EffectOutputCount());
257 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); 253 EXPECT_EQ(1, op->ValueOutputCount());
258 } 254 }
259 TRACED_FOREACH(double, v1, kFloatValues) { 255 TRACED_FOREACH(double, v1, kFloatValues) {
260 TRACED_FOREACH(double, v2, kFloatValues) { 256 TRACED_FOREACH(double, v2, kFloatValues) {
261 const Operator* op1 = common()->NumberConstant(v1); 257 const Operator* op1 = common()->NumberConstant(v1);
262 const Operator* op2 = common()->NumberConstant(v2); 258 const Operator* op2 = common()->NumberConstant(v2);
263 EXPECT_EQ(bit_cast<uint64_t>(v1) == bit_cast<uint64_t>(v2), 259 EXPECT_EQ(bit_cast<uint64_t>(v1) == bit_cast<uint64_t>(v2),
264 op1->Equals(op2)); 260 op1->Equals(op2));
265 } 261 }
266 } 262 }
267 } 263 }
268 264
269 265
270 TEST_F(CommonOperatorTest, ValueEffect) { 266 TEST_F(CommonOperatorTest, ValueEffect) {
271 TRACED_FOREACH(int, arguments, kArguments) { 267 TRACED_FOREACH(int, arguments, kArguments) {
272 const Operator* op = common()->ValueEffect(arguments); 268 const Operator* op = common()->ValueEffect(arguments);
273 EXPECT_EQ(arguments, OperatorProperties::GetValueInputCount(op)); 269 EXPECT_EQ(arguments, op->ValueInputCount());
274 EXPECT_EQ(arguments, OperatorProperties::GetTotalInputCount(op)); 270 EXPECT_EQ(arguments, OperatorProperties::GetTotalInputCount(op));
275 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); 271 EXPECT_EQ(0, op->ControlOutputCount());
276 EXPECT_EQ(1, OperatorProperties::GetEffectOutputCount(op)); 272 EXPECT_EQ(1, op->EffectOutputCount());
277 EXPECT_EQ(0, OperatorProperties::GetValueOutputCount(op)); 273 EXPECT_EQ(0, op->ValueOutputCount());
278 } 274 }
279 } 275 }
280 276
281 277
282 TEST_F(CommonOperatorTest, Finish) { 278 TEST_F(CommonOperatorTest, Finish) {
283 TRACED_FOREACH(int, arguments, kArguments) { 279 TRACED_FOREACH(int, arguments, kArguments) {
284 const Operator* op = common()->Finish(arguments); 280 const Operator* op = common()->Finish(arguments);
285 EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); 281 EXPECT_EQ(1, op->ValueInputCount());
286 EXPECT_EQ(arguments, OperatorProperties::GetEffectInputCount(op)); 282 EXPECT_EQ(arguments, op->EffectInputCount());
287 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); 283 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op));
288 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); 284 EXPECT_EQ(0, op->ControlOutputCount());
289 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); 285 EXPECT_EQ(0, op->EffectOutputCount());
290 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); 286 EXPECT_EQ(1, op->ValueOutputCount());
291 } 287 }
292 } 288 }
293 289
294 } // namespace compiler 290 } // namespace compiler
295 } // namespace internal 291 } // namespace internal
296 } // namespace v8 292 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-js-typed-lowering.cc ('k') | test/unittests/compiler/js-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698