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

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

Issue 2190743003: [turbofan] Remove eager frame state from shift operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_contrib-2191883002
Patch Set: Rebased. Created 4 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
« no previous file with comments | « src/compiler/operator-properties.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 // JSShiftLeft 417 // JSShiftLeft
418 418
419 419
420 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { 420 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) {
421 BinaryOperationHints const hints = BinaryOperationHints::Any(); 421 BinaryOperationHints const hints = BinaryOperationHints::Any();
422 Node* const lhs = Parameter(Type::Signed32()); 422 Node* const lhs = Parameter(Type::Signed32());
423 Node* const context = UndefinedConstant(); 423 Node* const context = UndefinedConstant();
424 Node* const effect = graph()->start(); 424 Node* const effect = graph()->start();
425 Node* const control = graph()->start(); 425 Node* const control = graph()->start();
426 TRACED_FORRANGE(double, rhs, 0, 31) { 426 TRACED_FORRANGE(double, rhs, 0, 31) {
427 Reduction r = Reduce(graph()->NewNode( 427 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hints), lhs,
428 javascript()->ShiftLeft(hints), lhs, NumberConstant(rhs), context, 428 NumberConstant(rhs), context,
429 EmptyFrameState(), EmptyFrameState(), effect, control)); 429 EmptyFrameState(), effect, control));
430 ASSERT_TRUE(r.Changed()); 430 ASSERT_TRUE(r.Changed());
431 EXPECT_THAT(r.replacement(), 431 EXPECT_THAT(r.replacement(),
432 IsNumberShiftLeft(lhs, IsNumberConstant(BitEq(rhs)))); 432 IsNumberShiftLeft(lhs, IsNumberConstant(BitEq(rhs))));
433 } 433 }
434 } 434 }
435 435
436 436
437 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { 437 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) {
438 BinaryOperationHints const hints = BinaryOperationHints::Any(); 438 BinaryOperationHints const hints = BinaryOperationHints::Any();
439 Node* const lhs = Parameter(Type::Signed32()); 439 Node* const lhs = Parameter(Type::Signed32());
440 Node* const rhs = Parameter(Type::Unsigned32()); 440 Node* const rhs = Parameter(Type::Unsigned32());
441 Node* const context = UndefinedConstant(); 441 Node* const context = UndefinedConstant();
442 Node* const effect = graph()->start(); 442 Node* const effect = graph()->start();
443 Node* const control = graph()->start(); 443 Node* const control = graph()->start();
444 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hints), lhs, 444 Reduction r =
445 rhs, context, EmptyFrameState(), 445 Reduce(graph()->NewNode(javascript()->ShiftLeft(hints), lhs, rhs, context,
446 EmptyFrameState(), effect, control)); 446 EmptyFrameState(), effect, control));
447 ASSERT_TRUE(r.Changed()); 447 ASSERT_TRUE(r.Changed());
448 EXPECT_THAT(r.replacement(), IsNumberShiftLeft(lhs, rhs)); 448 EXPECT_THAT(r.replacement(), IsNumberShiftLeft(lhs, rhs));
449 } 449 }
450 450
451 TEST_F(JSTypedLoweringTest, JSShiftLeftWithTypeFeedback) { 451 TEST_F(JSTypedLoweringTest, JSShiftLeftWithTypeFeedback) {
452 BinaryOperationHints::Hint const feedback_types[] = { 452 BinaryOperationHints::Hint const feedback_types[] = {
453 BinaryOperationHints::kSignedSmall, 453 BinaryOperationHints::kSignedSmall,
454 BinaryOperationHints::kNumberOrOddball}; 454 BinaryOperationHints::kNumberOrOddball};
455 for (BinaryOperationHints::Hint feedback : feedback_types) { 455 for (BinaryOperationHints::Hint feedback : feedback_types) {
456 BinaryOperationHints const hints(feedback, feedback, feedback); 456 BinaryOperationHints const hints(feedback, feedback, feedback);
457 Node* lhs = Parameter(Type::Number(), 2); 457 Node* lhs = Parameter(Type::Number(), 2);
458 Node* rhs = Parameter(Type::Number(), 3); 458 Node* rhs = Parameter(Type::Number(), 3);
459 Node* effect = graph()->start(); 459 Node* effect = graph()->start();
460 Node* control = graph()->start(); 460 Node* control = graph()->start();
461 Reduction r = Reduce(graph()->NewNode( 461 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hints), lhs,
462 javascript()->ShiftLeft(hints), lhs, rhs, UndefinedConstant(), 462 rhs, UndefinedConstant(),
463 EmptyFrameState(), EmptyFrameState(), effect, control)); 463 EmptyFrameState(), effect, control));
464 ASSERT_TRUE(r.Changed()); 464 ASSERT_TRUE(r.Changed());
465 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftLeft( 465 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftLeft(
466 feedback, lhs, rhs, effect, control)); 466 feedback, lhs, rhs, effect, control));
467 } 467 }
468 } 468 }
469 469
470 // ----------------------------------------------------------------------------- 470 // -----------------------------------------------------------------------------
471 // JSShiftRight 471 // JSShiftRight
472 472
473 473
474 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { 474 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) {
475 BinaryOperationHints const hints = BinaryOperationHints::Any(); 475 BinaryOperationHints const hints = BinaryOperationHints::Any();
476 Node* const lhs = Parameter(Type::Signed32()); 476 Node* const lhs = Parameter(Type::Signed32());
477 Node* const context = UndefinedConstant(); 477 Node* const context = UndefinedConstant();
478 Node* const effect = graph()->start(); 478 Node* const effect = graph()->start();
479 Node* const control = graph()->start(); 479 Node* const control = graph()->start();
480 TRACED_FORRANGE(double, rhs, 0, 31) { 480 TRACED_FORRANGE(double, rhs, 0, 31) {
481 Reduction r = Reduce(graph()->NewNode( 481 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hints), lhs,
482 javascript()->ShiftRight(hints), lhs, NumberConstant(rhs), context, 482 NumberConstant(rhs), context,
483 EmptyFrameState(), EmptyFrameState(), effect, control)); 483 EmptyFrameState(), effect, control));
484 ASSERT_TRUE(r.Changed()); 484 ASSERT_TRUE(r.Changed());
485 EXPECT_THAT(r.replacement(), 485 EXPECT_THAT(r.replacement(),
486 IsNumberShiftRight(lhs, IsNumberConstant(BitEq(rhs)))); 486 IsNumberShiftRight(lhs, IsNumberConstant(BitEq(rhs))));
487 } 487 }
488 } 488 }
489 489
490 490
491 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { 491 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) {
492 BinaryOperationHints const hints = BinaryOperationHints::Any(); 492 BinaryOperationHints const hints = BinaryOperationHints::Any();
493 Node* const lhs = Parameter(Type::Signed32()); 493 Node* const lhs = Parameter(Type::Signed32());
494 Node* const rhs = Parameter(Type::Unsigned32()); 494 Node* const rhs = Parameter(Type::Unsigned32());
495 Node* const context = UndefinedConstant(); 495 Node* const context = UndefinedConstant();
496 Node* const effect = graph()->start(); 496 Node* const effect = graph()->start();
497 Node* const control = graph()->start(); 497 Node* const control = graph()->start();
498 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hints), lhs, 498 Reduction r =
499 rhs, context, EmptyFrameState(), 499 Reduce(graph()->NewNode(javascript()->ShiftRight(hints), lhs, rhs,
500 EmptyFrameState(), effect, control)); 500 context, EmptyFrameState(), effect, control));
501 ASSERT_TRUE(r.Changed()); 501 ASSERT_TRUE(r.Changed());
502 EXPECT_THAT(r.replacement(), IsNumberShiftRight(lhs, rhs)); 502 EXPECT_THAT(r.replacement(), IsNumberShiftRight(lhs, rhs));
503 } 503 }
504 504
505 TEST_F(JSTypedLoweringTest, JSShiftRightWithTypeFeedback) { 505 TEST_F(JSTypedLoweringTest, JSShiftRightWithTypeFeedback) {
506 BinaryOperationHints::Hint const feedback_types[] = { 506 BinaryOperationHints::Hint const feedback_types[] = {
507 BinaryOperationHints::kSignedSmall, 507 BinaryOperationHints::kSignedSmall,
508 BinaryOperationHints::kNumberOrOddball}; 508 BinaryOperationHints::kNumberOrOddball};
509 for (BinaryOperationHints::Hint feedback : feedback_types) { 509 for (BinaryOperationHints::Hint feedback : feedback_types) {
510 BinaryOperationHints const hints(feedback, feedback, feedback); 510 BinaryOperationHints const hints(feedback, feedback, feedback);
511 Node* lhs = Parameter(Type::Number(), 2); 511 Node* lhs = Parameter(Type::Number(), 2);
512 Node* rhs = Parameter(Type::Number(), 3); 512 Node* rhs = Parameter(Type::Number(), 3);
513 Node* effect = graph()->start(); 513 Node* effect = graph()->start();
514 Node* control = graph()->start(); 514 Node* control = graph()->start();
515 Reduction r = Reduce(graph()->NewNode( 515 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hints), lhs,
516 javascript()->ShiftRight(hints), lhs, rhs, UndefinedConstant(), 516 rhs, UndefinedConstant(),
517 EmptyFrameState(), EmptyFrameState(), effect, control)); 517 EmptyFrameState(), effect, control));
518 ASSERT_TRUE(r.Changed()); 518 ASSERT_TRUE(r.Changed());
519 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRight( 519 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRight(
520 feedback, lhs, rhs, effect, control)); 520 feedback, lhs, rhs, effect, control));
521 } 521 }
522 } 522 }
523 523
524 // ----------------------------------------------------------------------------- 524 // -----------------------------------------------------------------------------
525 // JSShiftRightLogical 525 // JSShiftRightLogical
526 526
527 527
528 TEST_F(JSTypedLoweringTest, 528 TEST_F(JSTypedLoweringTest,
529 JSShiftRightLogicalWithUnsigned32AndConstant) { 529 JSShiftRightLogicalWithUnsigned32AndConstant) {
530 BinaryOperationHints const hints = BinaryOperationHints::Any(); 530 BinaryOperationHints const hints = BinaryOperationHints::Any();
531 Node* const lhs = Parameter(Type::Unsigned32()); 531 Node* const lhs = Parameter(Type::Unsigned32());
532 Node* const context = UndefinedConstant(); 532 Node* const context = UndefinedConstant();
533 Node* const effect = graph()->start(); 533 Node* const effect = graph()->start();
534 Node* const control = graph()->start(); 534 Node* const control = graph()->start();
535 TRACED_FORRANGE(double, rhs, 0, 31) { 535 TRACED_FORRANGE(double, rhs, 0, 31) {
536 Reduction r = Reduce(graph()->NewNode( 536 Reduction r = Reduce(graph()->NewNode(
537 javascript()->ShiftRightLogical(hints), lhs, NumberConstant(rhs), 537 javascript()->ShiftRightLogical(hints), lhs, NumberConstant(rhs),
538 context, EmptyFrameState(), EmptyFrameState(), effect, control)); 538 context, EmptyFrameState(), effect, control));
539 ASSERT_TRUE(r.Changed()); 539 ASSERT_TRUE(r.Changed());
540 EXPECT_THAT(r.replacement(), 540 EXPECT_THAT(r.replacement(),
541 IsNumberShiftRightLogical(lhs, IsNumberConstant(BitEq(rhs)))); 541 IsNumberShiftRightLogical(lhs, IsNumberConstant(BitEq(rhs))));
542 } 542 }
543 } 543 }
544 544
545 545
546 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndUnsigned32) { 546 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndUnsigned32) {
547 BinaryOperationHints const hints = BinaryOperationHints::Any(); 547 BinaryOperationHints const hints = BinaryOperationHints::Any();
548 Node* const lhs = Parameter(Type::Unsigned32()); 548 Node* const lhs = Parameter(Type::Unsigned32());
549 Node* const rhs = Parameter(Type::Unsigned32()); 549 Node* const rhs = Parameter(Type::Unsigned32());
550 Node* const context = UndefinedConstant(); 550 Node* const context = UndefinedConstant();
551 Node* const effect = graph()->start(); 551 Node* const effect = graph()->start();
552 Node* const control = graph()->start(); 552 Node* const control = graph()->start();
553 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hints), 553 Reduction r =
554 lhs, rhs, context, EmptyFrameState(), 554 Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hints), lhs, rhs,
555 EmptyFrameState(), effect, control)); 555 context, EmptyFrameState(), effect, control));
556 ASSERT_TRUE(r.Changed()); 556 ASSERT_TRUE(r.Changed());
557 EXPECT_THAT(r.replacement(), IsNumberShiftRightLogical(lhs, rhs)); 557 EXPECT_THAT(r.replacement(), IsNumberShiftRightLogical(lhs, rhs));
558 } 558 }
559 559
560 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithTypeFeedback) { 560 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithTypeFeedback) {
561 BinaryOperationHints::Hint const feedback_types[] = { 561 BinaryOperationHints::Hint const feedback_types[] = {
562 BinaryOperationHints::kSignedSmall, 562 BinaryOperationHints::kSignedSmall,
563 BinaryOperationHints::kNumberOrOddball}; 563 BinaryOperationHints::kNumberOrOddball};
564 for (BinaryOperationHints::Hint feedback : feedback_types) { 564 for (BinaryOperationHints::Hint feedback : feedback_types) {
565 BinaryOperationHints const hints(feedback, feedback, feedback); 565 BinaryOperationHints const hints(feedback, feedback, feedback);
566 Node* lhs = Parameter(Type::Number(), 2); 566 Node* lhs = Parameter(Type::Number(), 2);
567 Node* rhs = Parameter(Type::Number(), 3); 567 Node* rhs = Parameter(Type::Number(), 3);
568 Node* effect = graph()->start(); 568 Node* effect = graph()->start();
569 Node* control = graph()->start(); 569 Node* control = graph()->start();
570 Reduction r = Reduce(graph()->NewNode( 570 Reduction r = Reduce(graph()->NewNode(
571 javascript()->ShiftRightLogical(hints), lhs, rhs, UndefinedConstant(), 571 javascript()->ShiftRightLogical(hints), lhs, rhs, UndefinedConstant(),
572 EmptyFrameState(), EmptyFrameState(), effect, control)); 572 EmptyFrameState(), effect, control));
573 ASSERT_TRUE(r.Changed()); 573 ASSERT_TRUE(r.Changed());
574 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRightLogical( 574 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRightLogical(
575 feedback, lhs, rhs, effect, control)); 575 feedback, lhs, rhs, effect, control));
576 } 576 }
577 } 577 }
578 578
579 // ----------------------------------------------------------------------------- 579 // -----------------------------------------------------------------------------
580 // JSLoadContext 580 // JSLoadContext
581 581
582 582
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, 1002 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context,
1003 frame_state, effect, control); 1003 frame_state, effect, control);
1004 Reduction r = Reduce(instanceOf); 1004 Reduction r = Reduce(instanceOf);
1005 ASSERT_FALSE(r.Changed()); 1005 ASSERT_FALSE(r.Changed());
1006 ASSERT_EQ(instanceOf, dummy->InputAt(0)); 1006 ASSERT_EQ(instanceOf, dummy->InputAt(0));
1007 } 1007 }
1008 1008
1009 } // namespace compiler 1009 } // namespace compiler
1010 } // namespace internal 1010 } // namespace internal
1011 } // namespace v8 1011 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/operator-properties.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698