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

Side by Side Diff: test/unittests/compiler/change-lowering-unittest.cc

Issue 620803003: [turbofan] Add control input to Load and LoadElements. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
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/change-lowering.h" 5 #include "src/compiler/change-lowering.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/node-properties-inl.h" 7 #include "src/compiler/node-properties-inl.h"
8 #include "src/compiler/simplified-operator.h" 8 #include "src/compiler/simplified-operator.h"
9 #include "src/compiler/typer.h" 9 #include "src/compiler/typer.h"
10 #include "test/unittests/compiler/compiler-test-utils.h" 10 #include "test/unittests/compiler/compiler-test-utils.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 Matcher<Node*> IsAllocateHeapNumber(const Matcher<Node*>& effect_matcher, 80 Matcher<Node*> IsAllocateHeapNumber(const Matcher<Node*>& effect_matcher,
81 const Matcher<Node*>& control_matcher) { 81 const Matcher<Node*>& control_matcher) {
82 return IsCall( 82 return IsCall(
83 _, IsHeapConstant(Unique<HeapObject>::CreateImmovable( 83 _, IsHeapConstant(Unique<HeapObject>::CreateImmovable(
84 CEntryStub(isolate(), 1).GetCode())), 84 CEntryStub(isolate(), 1).GetCode())),
85 IsExternalConstant(ExternalReference( 85 IsExternalConstant(ExternalReference(
86 Runtime::FunctionForId(Runtime::kAllocateHeapNumber), isolate())), 86 Runtime::FunctionForId(Runtime::kAllocateHeapNumber), isolate())),
87 IsInt32Constant(0), IsNumberConstant(0.0), effect_matcher, 87 IsInt32Constant(0), IsNumberConstant(0.0), effect_matcher,
88 control_matcher); 88 control_matcher);
89 } 89 }
90 Matcher<Node*> IsLoadHeapNumber(const Matcher<Node*>& value_matcher,
91 const Matcher<Node*>& control_matcher) {
92 return IsLoad(kMachFloat64, value_matcher,
93 IsInt32Constant(HeapNumberValueOffset()), graph()->start(),
94 control_matcher);
95 }
90 Matcher<Node*> IsWordEqual(const Matcher<Node*>& lhs_matcher, 96 Matcher<Node*> IsWordEqual(const Matcher<Node*>& lhs_matcher,
91 const Matcher<Node*>& rhs_matcher) { 97 const Matcher<Node*>& rhs_matcher) {
92 return Is32() ? IsWord32Equal(lhs_matcher, rhs_matcher) 98 return Is32() ? IsWord32Equal(lhs_matcher, rhs_matcher)
93 : IsWord64Equal(lhs_matcher, rhs_matcher); 99 : IsWord64Equal(lhs_matcher, rhs_matcher);
94 } 100 }
95 101
96 private: 102 private:
97 SimplifiedOperatorBuilder simplified_; 103 SimplifiedOperatorBuilder simplified_;
98 }; 104 };
99 105
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 Node* val = Parameter(0); 225 Node* val = Parameter(0);
220 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val); 226 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val);
221 Reduction reduction = Reduce(node); 227 Reduction reduction = Reduce(node);
222 ASSERT_TRUE(reduction.Changed()); 228 ASSERT_TRUE(reduction.Changed());
223 229
224 Node* phi = reduction.replacement(); 230 Node* phi = reduction.replacement();
225 Capture<Node*> branch, if_true; 231 Capture<Node*> branch, if_true;
226 EXPECT_THAT( 232 EXPECT_THAT(
227 phi, 233 phi,
228 IsPhi( 234 IsPhi(
229 kMachFloat64, 235 kMachFloat64, IsLoadHeapNumber(val, CaptureEq(&if_true)),
230 IsLoad(kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()),
231 IsControlEffect(CaptureEq(&if_true))),
232 IsChangeInt32ToFloat64( 236 IsChangeInt32ToFloat64(
233 IsWord32Sar(val, IsInt32Constant(SmiShiftAmount()))), 237 IsWord32Sar(val, IsInt32Constant(SmiShiftAmount()))),
234 IsMerge( 238 IsMerge(
235 AllOf(CaptureEq(&if_true), 239 AllOf(CaptureEq(&if_true),
236 IsIfTrue(AllOf( 240 IsIfTrue(AllOf(
237 CaptureEq(&branch), 241 CaptureEq(&branch),
238 IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), 242 IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)),
239 graph()->start())))), 243 graph()->start())))),
240 IsIfFalse(CaptureEq(&branch))))); 244 IsIfFalse(CaptureEq(&branch)))));
241 } 245 }
242 246
243 247
244 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToInt32) { 248 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToInt32) {
245 STATIC_ASSERT(kSmiTag == 0); 249 STATIC_ASSERT(kSmiTag == 0);
246 STATIC_ASSERT(kSmiTagSize == 1); 250 STATIC_ASSERT(kSmiTagSize == 1);
247 251
248 Node* val = Parameter(0); 252 Node* val = Parameter(0);
249 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val); 253 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val);
250 Reduction reduction = Reduce(node); 254 Reduction reduction = Reduce(node);
251 ASSERT_TRUE(reduction.Changed()); 255 ASSERT_TRUE(reduction.Changed());
252 256
253 Node* phi = reduction.replacement(); 257 Node* phi = reduction.replacement();
254 Capture<Node*> branch, if_true; 258 Capture<Node*> branch, if_true;
255 EXPECT_THAT( 259 EXPECT_THAT(
256 phi, 260 phi,
257 IsPhi(kMachInt32, 261 IsPhi(kMachInt32,
258 IsChangeFloat64ToInt32(IsLoad( 262 IsChangeFloat64ToInt32(IsLoadHeapNumber(val, CaptureEq(&if_true))),
259 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()),
260 IsControlEffect(CaptureEq(&if_true)))),
261 IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())), 263 IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())),
262 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), 264 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))),
263 IsIfFalse(AllOf( 265 IsIfFalse(AllOf(
264 CaptureEq(&branch), 266 CaptureEq(&branch),
265 IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), 267 IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)),
266 graph()->start())))))); 268 graph()->start()))))));
267 } 269 }
268 270
269 271
270 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToUint32) { 272 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToUint32) {
271 STATIC_ASSERT(kSmiTag == 0); 273 STATIC_ASSERT(kSmiTag == 0);
272 STATIC_ASSERT(kSmiTagSize == 1); 274 STATIC_ASSERT(kSmiTagSize == 1);
273 275
274 Node* val = Parameter(0); 276 Node* val = Parameter(0);
275 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val); 277 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val);
276 Reduction reduction = Reduce(node); 278 Reduction reduction = Reduce(node);
277 ASSERT_TRUE(reduction.Changed()); 279 ASSERT_TRUE(reduction.Changed());
278 280
279 Node* phi = reduction.replacement(); 281 Node* phi = reduction.replacement();
280 Capture<Node*> branch, if_true; 282 Capture<Node*> branch, if_true;
281 EXPECT_THAT( 283 EXPECT_THAT(
282 phi, 284 phi,
283 IsPhi(kMachUint32, 285 IsPhi(kMachUint32,
284 IsChangeFloat64ToUint32(IsLoad( 286 IsChangeFloat64ToUint32(IsLoadHeapNumber(val, CaptureEq(&if_true))),
285 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()),
286 IsControlEffect(CaptureEq(&if_true)))),
287 IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())), 287 IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())),
288 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), 288 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))),
289 IsIfFalse(AllOf( 289 IsIfFalse(AllOf(
290 CaptureEq(&branch), 290 CaptureEq(&branch),
291 IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), 291 IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)),
292 graph()->start())))))); 292 graph()->start()))))));
293 } 293 }
294 294
295 295
296 TARGET_TEST_F(ChangeLowering32Test, ChangeUint32ToTagged) { 296 TARGET_TEST_F(ChangeLowering32Test, ChangeUint32ToTagged) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 Node* val = Parameter(0); 356 Node* val = Parameter(0);
357 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val); 357 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val);
358 Reduction reduction = Reduce(node); 358 Reduction reduction = Reduce(node);
359 ASSERT_TRUE(reduction.Changed()); 359 ASSERT_TRUE(reduction.Changed());
360 360
361 Node* phi = reduction.replacement(); 361 Node* phi = reduction.replacement();
362 Capture<Node*> branch, if_true; 362 Capture<Node*> branch, if_true;
363 EXPECT_THAT( 363 EXPECT_THAT(
364 phi, 364 phi,
365 IsPhi( 365 IsPhi(
366 kMachFloat64, 366 kMachFloat64, IsLoadHeapNumber(val, CaptureEq(&if_true)),
367 IsLoad(kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()),
368 IsControlEffect(CaptureEq(&if_true))),
369 IsChangeInt32ToFloat64(IsTruncateInt64ToInt32( 367 IsChangeInt32ToFloat64(IsTruncateInt64ToInt32(
370 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount())))), 368 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount())))),
371 IsMerge( 369 IsMerge(
372 AllOf(CaptureEq(&if_true), 370 AllOf(CaptureEq(&if_true),
373 IsIfTrue(AllOf( 371 IsIfTrue(AllOf(
374 CaptureEq(&branch), 372 CaptureEq(&branch),
375 IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), 373 IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)),
376 graph()->start())))), 374 graph()->start())))),
377 IsIfFalse(CaptureEq(&branch))))); 375 IsIfFalse(CaptureEq(&branch)))));
378 } 376 }
379 377
380 378
381 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToInt32) { 379 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToInt32) {
382 STATIC_ASSERT(kSmiTag == 0); 380 STATIC_ASSERT(kSmiTag == 0);
383 STATIC_ASSERT(kSmiTagSize == 1); 381 STATIC_ASSERT(kSmiTagSize == 1);
384 382
385 Node* val = Parameter(0); 383 Node* val = Parameter(0);
386 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val); 384 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val);
387 Reduction reduction = Reduce(node); 385 Reduction reduction = Reduce(node);
388 ASSERT_TRUE(reduction.Changed()); 386 ASSERT_TRUE(reduction.Changed());
389 387
390 Node* phi = reduction.replacement(); 388 Node* phi = reduction.replacement();
391 Capture<Node*> branch, if_true; 389 Capture<Node*> branch, if_true;
392 EXPECT_THAT( 390 EXPECT_THAT(
393 phi, 391 phi,
394 IsPhi(kMachInt32, 392 IsPhi(kMachInt32,
395 IsChangeFloat64ToInt32(IsLoad( 393 IsChangeFloat64ToInt32(IsLoadHeapNumber(val, CaptureEq(&if_true))),
396 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()),
397 IsControlEffect(CaptureEq(&if_true)))),
398 IsTruncateInt64ToInt32( 394 IsTruncateInt64ToInt32(
399 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount()))), 395 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount()))),
400 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), 396 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))),
401 IsIfFalse(AllOf( 397 IsIfFalse(AllOf(
402 CaptureEq(&branch), 398 CaptureEq(&branch),
403 IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), 399 IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)),
404 graph()->start())))))); 400 graph()->start()))))));
405 } 401 }
406 402
407 403
408 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToUint32) { 404 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToUint32) {
409 STATIC_ASSERT(kSmiTag == 0); 405 STATIC_ASSERT(kSmiTag == 0);
410 STATIC_ASSERT(kSmiTagSize == 1); 406 STATIC_ASSERT(kSmiTagSize == 1);
411 407
412 Node* val = Parameter(0); 408 Node* val = Parameter(0);
413 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val); 409 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val);
414 Reduction reduction = Reduce(node); 410 Reduction reduction = Reduce(node);
415 ASSERT_TRUE(reduction.Changed()); 411 ASSERT_TRUE(reduction.Changed());
416 412
417 Node* phi = reduction.replacement(); 413 Node* phi = reduction.replacement();
418 Capture<Node*> branch, if_true; 414 Capture<Node*> branch, if_true;
419 EXPECT_THAT( 415 EXPECT_THAT(
420 phi, 416 phi,
421 IsPhi(kMachUint32, 417 IsPhi(kMachUint32,
422 IsChangeFloat64ToUint32(IsLoad( 418 IsChangeFloat64ToUint32(IsLoadHeapNumber(val, CaptureEq(&if_true))),
423 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()),
424 IsControlEffect(CaptureEq(&if_true)))),
425 IsTruncateInt64ToInt32( 419 IsTruncateInt64ToInt32(
426 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount()))), 420 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount()))),
427 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), 421 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))),
428 IsIfFalse(AllOf( 422 IsIfFalse(AllOf(
429 CaptureEq(&branch), 423 CaptureEq(&branch),
430 IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), 424 IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)),
431 graph()->start())))))); 425 graph()->start()))))));
432 } 426 }
433 427
434 428
(...skipping 24 matching lines...) Expand all
459 IsIfTrue(AllOf(CaptureEq(&branch), 453 IsIfTrue(AllOf(CaptureEq(&branch),
460 IsBranch(IsUint32LessThanOrEqual( 454 IsBranch(IsUint32LessThanOrEqual(
461 val, IsInt32Constant(SmiMaxValue())), 455 val, IsInt32Constant(SmiMaxValue())),
462 graph()->start()))), 456 graph()->start()))),
463 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); 457 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch))))));
464 } 458 }
465 459
466 } // namespace compiler 460 } // namespace compiler
467 } // namespace internal 461 } // namespace internal
468 } // namespace v8 462 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-simplified-lowering.cc ('k') | test/unittests/compiler/common-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698