OLD | NEW |
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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 // ----------------------------------------------------------------------------- | 449 // ----------------------------------------------------------------------------- |
450 // JSShiftLeft | 450 // JSShiftLeft |
451 | 451 |
452 | 452 |
453 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { | 453 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { |
454 Node* const lhs = Parameter(Type::Signed32()); | 454 Node* const lhs = Parameter(Type::Signed32()); |
455 Node* const context = UndefinedConstant(); | 455 Node* const context = UndefinedConstant(); |
456 Node* const effect = graph()->start(); | 456 Node* const effect = graph()->start(); |
457 Node* const control = graph()->start(); | 457 Node* const control = graph()->start(); |
458 TRACED_FORRANGE(double, rhs, 0, 31) { | 458 TRACED_FORRANGE(double, rhs, 0, 31) { |
459 Reduction r = | 459 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
460 Reduce(graph()->NewNode(javascript()->ShiftLeft(LanguageMode::SLOPPY), | 460 Reduction r = |
461 lhs, NumberConstant(rhs), context, effect, | 461 Reduce(graph()->NewNode(javascript()->ShiftLeft(language_mode), lhs, |
462 control)); | 462 NumberConstant(rhs), context, effect, |
463 ASSERT_TRUE(r.Changed()); | 463 control)); |
464 EXPECT_THAT(r.replacement(), | 464 ASSERT_TRUE(r.Changed()); |
465 IsWord32Shl(lhs, IsNumberConstant(BitEq(rhs)))); | 465 EXPECT_THAT(r.replacement(), |
| 466 IsWord32Shl(lhs, IsNumberConstant(BitEq(rhs)))); |
| 467 } |
466 } | 468 } |
467 } | 469 } |
468 | 470 |
469 | 471 |
470 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { | 472 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { |
471 Node* const lhs = Parameter(Type::Signed32()); | 473 Node* const lhs = Parameter(Type::Signed32()); |
472 Node* const rhs = Parameter(Type::Unsigned32()); | 474 Node* const rhs = Parameter(Type::Unsigned32()); |
473 Node* const context = UndefinedConstant(); | 475 Node* const context = UndefinedConstant(); |
474 Node* const effect = graph()->start(); | 476 Node* const effect = graph()->start(); |
475 Node* const control = graph()->start(); | 477 Node* const control = graph()->start(); |
476 Reduction r = | 478 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
477 Reduce(graph()->NewNode(javascript()->ShiftLeft(LanguageMode::SLOPPY), | 479 Reduction r = |
478 lhs, rhs, context, effect, control)); | 480 Reduce(graph()->NewNode(javascript()->ShiftLeft(language_mode), lhs, |
479 ASSERT_TRUE(r.Changed()); | 481 rhs, context, effect, control)); |
480 EXPECT_THAT(r.replacement(), | 482 ASSERT_TRUE(r.Changed()); |
481 IsWord32Shl(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | 483 EXPECT_THAT(r.replacement(), |
| 484 IsWord32Shl(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); |
| 485 } |
482 } | 486 } |
483 | 487 |
484 | 488 |
485 // ----------------------------------------------------------------------------- | 489 // ----------------------------------------------------------------------------- |
486 // JSShiftRight | 490 // JSShiftRight |
487 | 491 |
488 | 492 |
489 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { | 493 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { |
490 Node* const lhs = Parameter(Type::Signed32()); | 494 Node* const lhs = Parameter(Type::Signed32()); |
491 Node* const context = UndefinedConstant(); | 495 Node* const context = UndefinedConstant(); |
492 Node* const effect = graph()->start(); | 496 Node* const effect = graph()->start(); |
493 Node* const control = graph()->start(); | 497 Node* const control = graph()->start(); |
494 TRACED_FORRANGE(double, rhs, 0, 31) { | 498 TRACED_FORRANGE(double, rhs, 0, 31) { |
495 Reduction r = | 499 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
496 Reduce(graph()->NewNode(javascript()-> | 500 Reduction r = |
497 ShiftRight(LanguageMode::SLOPPY), lhs, | 501 Reduce(graph()->NewNode(javascript()-> ShiftRight(language_mode), lhs, |
498 NumberConstant(rhs), context, effect, control)); | 502 NumberConstant(rhs), context, effect, |
499 ASSERT_TRUE(r.Changed()); | 503 control)); |
500 EXPECT_THAT(r.replacement(), | 504 ASSERT_TRUE(r.Changed()); |
501 IsWord32Sar(lhs, IsNumberConstant(BitEq(rhs)))); | 505 EXPECT_THAT(r.replacement(), |
| 506 IsWord32Sar(lhs, IsNumberConstant(BitEq(rhs)))); |
| 507 } |
502 } | 508 } |
503 } | 509 } |
504 | 510 |
505 | 511 |
506 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { | 512 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { |
507 Node* const lhs = Parameter(Type::Signed32()); | 513 Node* const lhs = Parameter(Type::Signed32()); |
508 Node* const rhs = Parameter(Type::Unsigned32()); | 514 Node* const rhs = Parameter(Type::Unsigned32()); |
509 Node* const context = UndefinedConstant(); | 515 Node* const context = UndefinedConstant(); |
510 Node* const effect = graph()->start(); | 516 Node* const effect = graph()->start(); |
511 Node* const control = graph()->start(); | 517 Node* const control = graph()->start(); |
512 Reduction r = Reduce(graph()->NewNode(javascript()-> | 518 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
513 ShiftRight(LanguageMode::SLOPPY), | 519 Reduction r = Reduce(graph()->NewNode(javascript()-> |
514 lhs, rhs, context, effect, control)); | 520 ShiftRight(language_mode), lhs, rhs, |
515 ASSERT_TRUE(r.Changed()); | 521 context, effect, control)); |
516 EXPECT_THAT(r.replacement(), | 522 ASSERT_TRUE(r.Changed()); |
517 IsWord32Sar(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | 523 EXPECT_THAT(r.replacement(), |
| 524 IsWord32Sar(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); |
| 525 } |
518 } | 526 } |
519 | 527 |
520 | 528 |
521 // ----------------------------------------------------------------------------- | 529 // ----------------------------------------------------------------------------- |
522 // JSShiftRightLogical | 530 // JSShiftRightLogical |
523 | 531 |
524 | 532 |
525 TEST_F(JSTypedLoweringTest, | 533 TEST_F(JSTypedLoweringTest, |
526 JSShiftRightLogicalWithUnsigned32AndConstant) { | 534 JSShiftRightLogicalWithUnsigned32AndConstant) { |
527 Node* const lhs = Parameter(Type::Unsigned32()); | 535 Node* const lhs = Parameter(Type::Unsigned32()); |
528 Node* const context = UndefinedConstant(); | 536 Node* const context = UndefinedConstant(); |
529 Node* const effect = graph()->start(); | 537 Node* const effect = graph()->start(); |
530 Node* const control = graph()->start(); | 538 Node* const control = graph()->start(); |
531 TRACED_FORRANGE(double, rhs, 0, 31) { | 539 TRACED_FORRANGE(double, rhs, 0, 31) { |
532 Reduction r = | 540 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
533 Reduce(graph()->NewNode(javascript()-> | 541 Reduction r = |
534 ShiftRightLogical(LanguageMode::SLOPPY), | 542 Reduce(graph()->NewNode(javascript()-> |
535 lhs, NumberConstant(rhs), context, effect, | 543 ShiftRightLogical(language_mode), lhs, |
536 control)); | 544 NumberConstant(rhs), context, effect, |
537 ASSERT_TRUE(r.Changed()); | 545 control)); |
538 EXPECT_THAT(r.replacement(), | 546 ASSERT_TRUE(r.Changed()); |
539 IsWord32Shr(lhs, IsNumberConstant(BitEq(rhs)))); | 547 EXPECT_THAT(r.replacement(), |
| 548 IsWord32Shr(lhs, IsNumberConstant(BitEq(rhs)))); |
| 549 } |
540 } | 550 } |
541 } | 551 } |
542 | 552 |
543 | 553 |
544 TEST_F(JSTypedLoweringTest, | 554 TEST_F(JSTypedLoweringTest, |
545 JSShiftRightLogicalWithUnsigned32AndUnsigned32) { | 555 JSShiftRightLogicalWithUnsigned32AndUnsigned32) { |
546 Node* const lhs = Parameter(Type::Unsigned32()); | 556 Node* const lhs = Parameter(Type::Unsigned32()); |
547 Node* const rhs = Parameter(Type::Unsigned32()); | 557 Node* const rhs = Parameter(Type::Unsigned32()); |
548 Node* const context = UndefinedConstant(); | 558 Node* const context = UndefinedConstant(); |
549 Node* const effect = graph()->start(); | 559 Node* const effect = graph()->start(); |
550 Node* const control = graph()->start(); | 560 Node* const control = graph()->start(); |
551 Reduction r = Reduce(graph()->NewNode(javascript()-> | 561 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
552 ShiftRightLogical(LanguageMode::SLOPPY), | 562 Reduction r = Reduce(graph()->NewNode(javascript()-> |
553 lhs, rhs, context, effect, control)); | 563 ShiftRightLogical(language_mode), lhs, |
554 ASSERT_TRUE(r.Changed()); | 564 rhs, context, effect, control)); |
555 EXPECT_THAT(r.replacement(), | 565 ASSERT_TRUE(r.Changed()); |
556 IsWord32Shr(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | 566 EXPECT_THAT(r.replacement(), |
| 567 IsWord32Shr(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); |
| 568 } |
557 } | 569 } |
558 | 570 |
559 | 571 |
560 // ----------------------------------------------------------------------------- | 572 // ----------------------------------------------------------------------------- |
561 // JSLoadContext | 573 // JSLoadContext |
562 | 574 |
563 | 575 |
564 TEST_F(JSTypedLoweringTest, JSLoadContext) { | 576 TEST_F(JSTypedLoweringTest, JSLoadContext) { |
565 Node* const context = Parameter(Type::Any()); | 577 Node* const context = Parameter(Type::Any()); |
566 Node* const effect = graph()->start(); | 578 Node* const effect = graph()->start(); |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 EXPECT_THAT( | 962 EXPECT_THAT( |
951 r.replacement(), | 963 r.replacement(), |
952 IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( | 964 IsCall(_, IsHeapConstant(Unique<HeapObject>::CreateImmovable( |
953 CodeFactory::FastCloneShallowObject(isolate(), 6).code())), | 965 CodeFactory::FastCloneShallowObject(isolate(), 6).code())), |
954 input0, input1, input2, _, context, frame_state, effect, control)); | 966 input0, input1, input2, _, context, frame_state, effect, control)); |
955 } | 967 } |
956 | 968 |
957 } // namespace compiler | 969 } // namespace compiler |
958 } // namespace internal | 970 } // namespace internal |
959 } // namespace v8 | 971 } // namespace v8 |
OLD | NEW |