OLD | NEW |
---|---|
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC. |
6 #if defined(TARGET_ARCH_DBC) | 6 #if defined(TARGET_ARCH_DBC) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 if (labels.fall_through != labels.true_label) { | 476 if (labels.fall_through != labels.true_label) { |
477 // The preceeding Jump instruction will be skipped if the test succeeds. | 477 // The preceeding Jump instruction will be skipped if the test succeeds. |
478 // If we aren't falling through to the true case, then we have to do | 478 // If we aren't falling through to the true case, then we have to do |
479 // a Jump to it here. | 479 // a Jump to it here. |
480 __ Jump(labels.true_label); | 480 __ Jump(labels.true_label); |
481 } | 481 } |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 | 485 |
486 Condition StrictCompareInstr::GetPredictedCondition(FlowGraphCompiler* compiler, | |
Vyacheslav Egorov (Google)
2017/06/15 11:32:46
The name GetPredicatedCondition(...) is very confu
erikcorry
2017/06/19 07:15:09
Done.
| |
487 BranchLabels labels) { | |
488 return (labels.fall_through == labels.false_label) ? NEXT_IS_TRUE | |
489 : NEXT_IS_FALSE; | |
490 } | |
491 | |
492 | |
486 Condition StrictCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler, | 493 Condition StrictCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
487 BranchLabels labels) { | 494 BranchLabels labels) { |
488 ASSERT((kind() == Token::kNE_STRICT) || (kind() == Token::kEQ_STRICT)); | 495 ASSERT((kind() == Token::kNE_STRICT) || (kind() == Token::kEQ_STRICT)); |
489 | 496 |
490 Token::Kind comparison; | 497 Token::Kind comparison; |
491 Condition condition; | 498 Condition condition; |
492 if (labels.fall_through == labels.false_label) { | 499 if (labels.fall_through == labels.false_label) { |
493 condition = NEXT_IS_TRUE; | 500 condition = NEXT_IS_TRUE; |
494 comparison = kind(); | 501 comparison = kind(); |
495 } else { | 502 } else { |
(...skipping 19 matching lines...) Expand all Loading... | |
515 __ Emit(Bytecode::Encode((comparison == Token::kEQ_STRICT) ? eq_op : ne_op, | 522 __ Emit(Bytecode::Encode((comparison == Token::kEQ_STRICT) ? eq_op : ne_op, |
516 locs()->in(0).reg(), locs()->in(1).reg())); | 523 locs()->in(0).reg(), locs()->in(1).reg())); |
517 } | 524 } |
518 | 525 |
519 if (needs_number_check() && token_pos().IsReal()) { | 526 if (needs_number_check() && token_pos().IsReal()) { |
520 compiler->RecordSafepoint(locs()); | 527 compiler->RecordSafepoint(locs()); |
521 compiler->AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, deopt_id_, | 528 compiler->AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, deopt_id_, |
522 token_pos()); | 529 token_pos()); |
523 } | 530 } |
524 | 531 |
525 return condition; | 532 return condition; |
Vyacheslav Egorov (Google)
2017/06/15 11:32:46
this should probably be return GetPredictedConditi
erikcorry
2017/06/19 07:15:09
We assert that they return the same. I think that'
| |
526 } | 533 } |
527 | 534 |
528 | 535 |
529 void StrictCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 536 DEFINE_MAKE_LOCATION_SUMMARY(StrictCompare, |
530 BranchInstr* branch) { | 537 2, |
531 ASSERT((kind() == Token::kEQ_STRICT) || (kind() == Token::kNE_STRICT)); | 538 Location::RequiresRegister(), |
539 needs_number_check() ? LocationSummary::kCall | |
540 : LocationSummary::kNoCall) | |
532 | 541 |
542 | |
543 template <intptr_t N, | |
544 typename ThrowsTrait, | |
545 template <typename Impure, typename Pure> class CSETrait> | |
546 void TemplateComparison<N, ThrowsTrait, CSETrait>::EmitBranchCode( | |
547 FlowGraphCompiler* compiler, | |
548 BranchInstr* branch) { | |
533 BranchLabels labels = compiler->CreateBranchLabels(branch); | 549 BranchLabels labels = compiler->CreateBranchLabels(branch); |
534 Condition true_condition = EmitComparisonCode(compiler, labels); | 550 Condition true_condition = EmitComparisonCode(compiler, labels); |
535 EmitBranchOnCondition(compiler, true_condition, labels); | 551 if (true_condition != INVALID_CONDITION) { |
552 EmitBranchOnCondition(compiler, true_condition, labels); | |
553 } | |
536 } | 554 } |
537 | 555 |
538 | 556 |
539 EMIT_NATIVE_CODE(StrictCompare, | 557 // IA32 compiler needs this to link. |
540 2, | 558 template <> |
541 Location::RequiresRegister(), | 559 void TemplateComparison<2, Throws, NoCSE>::EmitBranchCode( |
542 needs_number_check() ? LocationSummary::kCall | 560 FlowGraphCompiler* compiler, |
543 : LocationSummary::kNoCall) { | 561 BranchInstr* branch) { |
544 ASSERT((kind() == Token::kEQ_STRICT) || (kind() == Token::kNE_STRICT)); | 562 UNREACHABLE(); |
563 } | |
545 | 564 |
565 | |
566 template <intptr_t N, | |
567 typename ThrowsTrait, | |
568 template <typename Impure, typename Pure> class CSETrait> | |
569 void TemplateComparison<N, ThrowsTrait, CSETrait>::EmitNativeCode( | |
570 FlowGraphCompiler* compiler) { | |
546 Label is_true, is_false; | 571 Label is_true, is_false; |
547 BranchLabels labels = {&is_true, &is_false, &is_false}; | 572 BranchLabels labels = {&is_true, &is_false, &is_false}; |
548 Condition true_condition = EmitComparisonCode(compiler, labels); | 573 Condition true_condition = this->GetPredictedCondition(compiler, labels); |
549 EmitBranchOnCondition(compiler, true_condition, labels); | 574 if (true_condition == INVALID_CONDITION || !compiler->is_optimizing() || |
550 Label done; | 575 is_true.IsLinked() || is_false.IsLinked()) { |
551 if (compiler->is_optimizing()) { | 576 Condition actual_condition = EmitComparisonCode(compiler, labels); |
552 const Register result = locs()->out(0).reg(); | 577 ASSERT(actual_condition == true_condition); |
553 __ Bind(&is_false); | 578 if (true_condition != INVALID_CONDITION) { |
554 __ LoadConstant(result, Bool::False()); | 579 EmitBranchOnCondition(compiler, true_condition, labels); |
555 __ Jump(&done); | 580 } |
556 __ Bind(&is_true); | 581 Label done; |
557 __ LoadConstant(result, Bool::True()); | |
558 __ Bind(&done); | |
559 } else { | |
560 __ Bind(&is_false); | 582 __ Bind(&is_false); |
561 __ PushConstant(Bool::False()); | 583 __ PushConstant(Bool::False()); |
562 __ Jump(&done); | 584 __ Jump(&done); |
563 __ Bind(&is_true); | 585 __ Bind(&is_true); |
564 __ PushConstant(Bool::True()); | 586 __ PushConstant(Bool::True()); |
565 __ Bind(&done); | 587 __ Bind(&done); |
588 } else { | |
589 const Register result = this->locs()->out(0).reg(); | |
590 __ LoadConstant( | |
591 result, true_condition == NEXT_IS_TRUE ? Bool::False() : Bool::True()); | |
592 Condition actual_condition = EmitComparisonCode(compiler, labels); | |
593 ASSERT(actual_condition == true_condition); | |
594 __ LoadConstant( | |
595 result, true_condition == NEXT_IS_TRUE ? Bool::True() : Bool::False()); | |
566 } | 596 } |
567 } | 597 } |
568 | 598 |
569 | 599 |
600 // IA32 compiler needs this to link (for the simmips config). | |
601 template <> | |
602 void TemplateComparison<2, Throws, NoCSE>::EmitNativeCode( | |
603 FlowGraphCompiler* compiler) { | |
604 UNREACHABLE(); | |
605 } | |
606 | |
607 | |
608 // Explicit template instantiations. | |
609 template void TemplateComparison<1, NoThrow, Pure>::EmitNativeCode( | |
610 FlowGraphCompiler*); | |
611 template void TemplateComparison<2, NoThrow, Pure>::EmitNativeCode( | |
612 FlowGraphCompiler*); | |
613 template void TemplateComparison<1, NoThrow, Pure>::EmitBranchCode( | |
614 FlowGraphCompiler* compiler, | |
615 BranchInstr* branch); | |
616 template void TemplateComparison<2, NoThrow, Pure>::EmitBranchCode( | |
617 FlowGraphCompiler* compiler, | |
618 BranchInstr* branch); | |
619 | |
620 | |
570 LocationSummary* BranchInstr::MakeLocationSummary(Zone* zone, bool opt) const { | 621 LocationSummary* BranchInstr::MakeLocationSummary(Zone* zone, bool opt) const { |
571 comparison()->InitializeLocationSummary(zone, opt); | 622 comparison()->InitializeLocationSummary(zone, opt); |
572 if (!comparison()->HasLocs()) { | 623 if (!comparison()->HasLocs()) { |
573 return NULL; | 624 return NULL; |
574 } | 625 } |
575 // Branches don't produce a result. | 626 // Branches don't produce a result. |
576 comparison()->locs()->set_out(0, Location::NoLocation()); | 627 comparison()->locs()->set_out(0, Location::NoLocation()); |
577 return comparison()->locs(); | 628 return comparison()->locs(); |
578 } | 629 } |
579 | 630 |
(...skipping 14 matching lines...) Expand all Loading... | |
594 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); | 645 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); |
595 } | 646 } |
596 // We can fall through if the successor is the next block in the list. | 647 // We can fall through if the successor is the next block in the list. |
597 // Otherwise, we need a jump. | 648 // Otherwise, we need a jump. |
598 if (!compiler->CanFallThroughTo(successor())) { | 649 if (!compiler->CanFallThroughTo(successor())) { |
599 __ Jump(compiler->GetJumpLabel(successor())); | 650 __ Jump(compiler->GetJumpLabel(successor())); |
600 } | 651 } |
601 } | 652 } |
602 | 653 |
603 | 654 |
655 Condition TestSmiInstr::GetPredictedCondition(FlowGraphCompiler* compiler, | |
656 BranchLabels labels) { | |
657 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); | |
658 return (kind() == Token::kEQ) ? NEXT_IS_TRUE : NEXT_IS_FALSE; | |
659 } | |
660 | |
661 | |
604 Condition TestSmiInstr::EmitComparisonCode(FlowGraphCompiler* compiler, | 662 Condition TestSmiInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
605 BranchLabels labels) { | 663 BranchLabels labels) { |
606 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); | 664 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); |
607 Register left = locs()->in(0).reg(); | 665 Register left = locs()->in(0).reg(); |
608 Register right = locs()->in(1).reg(); | 666 Register right = locs()->in(1).reg(); |
609 __ TestSmi(left, right); | 667 __ TestSmi(left, right); |
610 return (kind() == Token::kEQ) ? NEXT_IS_TRUE : NEXT_IS_FALSE; | 668 return (kind() == Token::kEQ) ? NEXT_IS_TRUE : NEXT_IS_FALSE; |
Vyacheslav Egorov (Google)
2017/06/15 11:32:46
should this get return GetPredictedCondition()?
erikcorry
2017/06/19 07:15:09
See above.
| |
611 } | 669 } |
612 | 670 |
613 | 671 |
614 void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 672 DEFINE_MAKE_LOCATION_SUMMARY(TestSmi, |
615 BranchInstr* branch) { | 673 2, |
616 BranchLabels labels = compiler->CreateBranchLabels(branch); | 674 Location::RequiresRegister(), |
617 Condition true_condition = EmitComparisonCode(compiler, labels); | 675 LocationSummary::kNoCall) |
618 EmitBranchOnCondition(compiler, true_condition, labels); | |
619 } | |
620 | |
621 | |
622 EMIT_NATIVE_CODE(TestSmi, | |
623 2, | |
624 Location::RequiresRegister(), | |
625 LocationSummary::kNoCall) { | |
626 // Never emitted outside of the BranchInstr. | |
627 UNREACHABLE(); | |
628 } | |
629 | 676 |
630 | 677 |
631 Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler, | 678 Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
632 BranchLabels labels) { | 679 BranchLabels labels) { |
633 ASSERT((kind() == Token::kIS) || (kind() == Token::kISNOT)); | 680 ASSERT((kind() == Token::kIS) || (kind() == Token::kISNOT)); |
634 const Register value = locs()->in(0).reg(); | 681 const Register value = locs()->in(0).reg(); |
635 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0; | 682 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0; |
636 | 683 |
637 const ZoneGrowableArray<intptr_t>& data = cid_results(); | 684 const ZoneGrowableArray<intptr_t>& data = cid_results(); |
638 const intptr_t num_cases = data.length() / 2; | 685 const intptr_t num_cases = data.length() / 2; |
(...skipping 16 matching lines...) Expand all Loading... | |
655 // that are in the list. These must be all the same (see asserts in the | 702 // that are in the list. These must be all the same (see asserts in the |
656 // constructor). | 703 // constructor). |
657 Label* target = result ? labels.false_label : labels.true_label; | 704 Label* target = result ? labels.false_label : labels.true_label; |
658 __ Jump(target); | 705 __ Jump(target); |
659 } | 706 } |
660 | 707 |
661 return NEXT_IS_TRUE; | 708 return NEXT_IS_TRUE; |
662 } | 709 } |
663 | 710 |
664 | 711 |
665 void TestCidsInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 712 Condition TestCidsInstr::GetPredictedCondition(FlowGraphCompiler* compiler, |
666 BranchInstr* branch) { | 713 BranchLabels labels) { |
667 BranchLabels labels = compiler->CreateBranchLabels(branch); | 714 return NEXT_IS_TRUE; |
668 Condition true_condition = EmitComparisonCode(compiler, labels); | |
669 EmitBranchOnCondition(compiler, true_condition, labels); | |
670 } | 715 } |
671 | 716 |
672 | 717 |
673 EMIT_NATIVE_CODE(TestCids, | 718 DEFINE_MAKE_LOCATION_SUMMARY(TestCids, |
674 1, | 719 1, |
675 Location::RequiresRegister(), | 720 Location::RequiresRegister(), |
676 LocationSummary::kNoCall) { | 721 LocationSummary::kNoCall) |
677 Register result_reg = locs()->out(0).reg(); | |
678 Label is_true, is_false, done; | |
679 BranchLabels labels = {&is_true, &is_false, &is_false}; | |
680 EmitComparisonCode(compiler, labels); | |
681 __ Jump(&is_true); | |
682 __ Bind(&is_false); | |
683 __ LoadConstant(result_reg, Bool::False()); | |
684 __ Jump(&done); | |
685 __ Bind(&is_true); | |
686 __ LoadConstant(result_reg, Bool::True()); | |
687 __ Bind(&done); | |
688 } | |
689 | 722 |
690 | 723 |
691 EMIT_NATIVE_CODE(CreateArray, | 724 EMIT_NATIVE_CODE(CreateArray, |
692 2, | 725 2, |
693 Location::RequiresRegister(), | 726 Location::RequiresRegister(), |
694 LocationSummary::kCall) { | 727 LocationSummary::kCall) { |
695 if (compiler->is_optimizing()) { | 728 if (compiler->is_optimizing()) { |
696 const Register length = locs()->in(kLengthPos).reg(); | 729 const Register length = locs()->in(kLengthPos).reg(); |
697 const Register type_arguments = locs()->in(kElementTypePos).reg(); | 730 const Register type_arguments = locs()->in(kElementTypePos).reg(); |
698 const Register out = locs()->out(0).reg(); | 731 const Register out = locs()->out(0).reg(); |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1746 __ DDiv(result, left, right); | 1779 __ DDiv(result, left, right); |
1747 break; | 1780 break; |
1748 default: | 1781 default: |
1749 UNREACHABLE(); | 1782 UNREACHABLE(); |
1750 } | 1783 } |
1751 } | 1784 } |
1752 | 1785 |
1753 | 1786 |
1754 Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, | 1787 Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
1755 BranchLabels labels) { | 1788 BranchLabels labels) { |
1756 UNREACHABLE(); | |
1757 return Condition(); | |
1758 } | |
1759 | |
1760 | |
1761 void DoubleTestOpInstr::EmitBranchCode(FlowGraphCompiler* compiler, | |
1762 BranchInstr* branch) { | |
1763 ASSERT(compiler->is_optimizing()); | 1789 ASSERT(compiler->is_optimizing()); |
1764 BranchLabels labels = compiler->CreateBranchLabels(branch); | |
1765 const Register value = locs()->in(0).reg(); | 1790 const Register value = locs()->in(0).reg(); |
1766 switch (op_kind()) { | 1791 switch (op_kind()) { |
1767 case MethodRecognizer::kDouble_getIsNaN: | 1792 case MethodRecognizer::kDouble_getIsNaN: |
1768 __ DoubleIsNaN(value); | 1793 __ DoubleIsNaN(value); |
1769 break; | 1794 break; |
1770 case MethodRecognizer::kDouble_getIsInfinite: | 1795 case MethodRecognizer::kDouble_getIsInfinite: |
1771 __ DoubleIsInfinite(value); | 1796 __ DoubleIsInfinite(value); |
1772 break; | 1797 break; |
1773 default: | 1798 default: |
1774 UNREACHABLE(); | 1799 UNREACHABLE(); |
1775 } | 1800 } |
1776 const bool is_negated = kind() != Token::kEQ; | 1801 const bool is_negated = kind() != Token::kEQ; |
Vyacheslav Egorov (Google)
2017/06/15 11:32:46
return GetPredictedCondition();
erikcorry
2017/06/19 07:15:09
See above
| |
1777 EmitBranchOnCondition(compiler, is_negated ? NEXT_IS_FALSE : NEXT_IS_TRUE, | 1802 return is_negated ? NEXT_IS_FALSE : NEXT_IS_TRUE; |
1778 labels); | |
1779 } | 1803 } |
1780 | 1804 |
1781 | 1805 |
1782 EMIT_NATIVE_CODE(DoubleTestOp, 1, Location::RequiresRegister()) { | 1806 Condition DoubleTestOpInstr::GetPredictedCondition(FlowGraphCompiler* compiler, |
1783 ASSERT(compiler->is_optimizing()); | 1807 BranchLabels labels) { |
1784 const Register value = locs()->in(0).reg(); | |
1785 const Register result = locs()->out(0).reg(); | |
1786 const bool is_negated = kind() != Token::kEQ; | 1808 const bool is_negated = kind() != Token::kEQ; |
1787 __ LoadConstant(result, is_negated ? Bool::True() : Bool::False()); | 1809 return is_negated ? NEXT_IS_FALSE : NEXT_IS_TRUE; |
1788 switch (op_kind()) { | |
1789 case MethodRecognizer::kDouble_getIsNaN: | |
1790 __ DoubleIsNaN(value); | |
1791 break; | |
1792 case MethodRecognizer::kDouble_getIsInfinite: | |
1793 __ DoubleIsInfinite(value); | |
1794 break; | |
1795 default: | |
1796 UNREACHABLE(); | |
1797 } | |
1798 __ LoadConstant(result, is_negated ? Bool::False() : Bool::True()); | |
1799 } | 1810 } |
1800 | 1811 |
1801 | 1812 |
1813 DEFINE_MAKE_LOCATION_SUMMARY(DoubleTestOp, 1, Location::RequiresRegister()) | |
1814 | |
1815 | |
1802 EMIT_NATIVE_CODE(UnaryDoubleOp, 1, Location::RequiresRegister()) { | 1816 EMIT_NATIVE_CODE(UnaryDoubleOp, 1, Location::RequiresRegister()) { |
1803 const Register value = locs()->in(0).reg(); | 1817 const Register value = locs()->in(0).reg(); |
1804 const Register result = locs()->out(0).reg(); | 1818 const Register result = locs()->out(0).reg(); |
1805 __ DNeg(result, value); | 1819 __ DNeg(result, value); |
1806 } | 1820 } |
1807 | 1821 |
1808 | 1822 |
1809 EMIT_NATIVE_CODE(MathUnary, 1, Location::RequiresRegister()) { | 1823 EMIT_NATIVE_CODE(MathUnary, 1, Location::RequiresRegister()) { |
1810 const Register value = locs()->in(0).reg(); | 1824 const Register value = locs()->in(0).reg(); |
1811 const Register result = locs()->out(0).reg(); | 1825 const Register result = locs()->out(0).reg(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1966 Token::Kind kind, | 1980 Token::Kind kind, |
1967 BranchLabels labels) { | 1981 BranchLabels labels) { |
1968 const Register left = locs->in(0).reg(); | 1982 const Register left = locs->in(0).reg(); |
1969 const Register right = locs->in(1).reg(); | 1983 const Register right = locs->in(1).reg(); |
1970 Token::Kind comparison = kind; | 1984 Token::Kind comparison = kind; |
1971 Condition condition = NEXT_IS_TRUE; | 1985 Condition condition = NEXT_IS_TRUE; |
1972 if (labels.fall_through != labels.false_label) { | 1986 if (labels.fall_through != labels.false_label) { |
1973 // If we aren't falling through to the false label, we can save a Jump | 1987 // If we aren't falling through to the false label, we can save a Jump |
1974 // instruction in the case that the true case is the fall through by | 1988 // instruction in the case that the true case is the fall through by |
1975 // flipping the sense of the test such that the instruction following the | 1989 // flipping the sense of the test such that the instruction following the |
1976 // test is the Jump to the false label. | 1990 // test is the Jump to the false label. In the case where both labels are |
1991 // null we don't flip the sense of the test. | |
1977 condition = NEXT_IS_FALSE; | 1992 condition = NEXT_IS_FALSE; |
1978 comparison = FlipCondition(kind); | 1993 comparison = FlipCondition(kind); |
1979 } | 1994 } |
1980 __ Emit(Bytecode::Encode(OpcodeForSmiCondition(comparison), left, right)); | 1995 __ Emit(Bytecode::Encode(OpcodeForSmiCondition(comparison), left, right)); |
1981 return condition; | 1996 return condition; |
1982 } | 1997 } |
1983 | 1998 |
1984 | 1999 |
1985 static Condition EmitDoubleComparisonOp(FlowGraphCompiler* compiler, | 2000 static Condition EmitDoubleComparisonOp(FlowGraphCompiler* compiler, |
1986 LocationSummary* locs, | 2001 LocationSummary* locs, |
(...skipping 16 matching lines...) Expand all Loading... | |
2003 BranchLabels labels) { | 2018 BranchLabels labels) { |
2004 if (operation_cid() == kSmiCid) { | 2019 if (operation_cid() == kSmiCid) { |
2005 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); | 2020 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); |
2006 } else { | 2021 } else { |
2007 ASSERT(operation_cid() == kDoubleCid); | 2022 ASSERT(operation_cid() == kDoubleCid); |
2008 return EmitDoubleComparisonOp(compiler, locs(), kind()); | 2023 return EmitDoubleComparisonOp(compiler, locs(), kind()); |
2009 } | 2024 } |
2010 } | 2025 } |
2011 | 2026 |
2012 | 2027 |
2013 EMIT_NATIVE_CODE(EqualityCompare, 2, Location::RequiresRegister()) { | 2028 Condition EqualityCompareInstr::GetPredictedCondition( |
2014 ASSERT(compiler->is_optimizing()); | 2029 FlowGraphCompiler* compiler, |
2015 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); | 2030 BranchLabels labels) { |
2016 Label is_true, is_false; | 2031 if (operation_cid() == kSmiCid) { |
2017 // These labels are not used. They are arranged so that EmitComparisonCode | 2032 return (labels.fall_through != labels.false_label) ? NEXT_IS_FALSE |
2018 // emits a test that executes the following instruction when the test | 2033 : NEXT_IS_TRUE; |
2019 // succeeds. | 2034 } else { |
2020 BranchLabels labels = {&is_true, &is_false, &is_false}; | 2035 ASSERT(operation_cid() == kDoubleCid); |
2021 const Register result = locs()->out(0).reg(); | 2036 return NEXT_IS_TRUE; |
2022 __ LoadConstant(result, Bool::False()); | 2037 } |
2023 Condition true_condition = EmitComparisonCode(compiler, labels); | |
2024 ASSERT(true_condition == NEXT_IS_TRUE); | |
2025 __ LoadConstant(result, Bool::True()); | |
2026 } | 2038 } |
2027 | 2039 |
2028 | 2040 |
2029 void EqualityCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 2041 DEFINE_MAKE_LOCATION_SUMMARY(EqualityCompare, 2, Location::RequiresRegister()); |
2030 BranchInstr* branch) { | |
2031 ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ)); | |
2032 BranchLabels labels = compiler->CreateBranchLabels(branch); | |
2033 Condition true_condition = EmitComparisonCode(compiler, labels); | |
2034 EmitBranchOnCondition(compiler, true_condition, labels); | |
2035 } | |
2036 | 2042 |
2037 | 2043 |
2038 Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, | 2044 Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
2039 BranchLabels labels) { | 2045 BranchLabels labels) { |
2040 if (operation_cid() == kSmiCid) { | 2046 if (operation_cid() == kSmiCid) { |
2041 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); | 2047 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); |
2042 } else { | 2048 } else { |
2043 ASSERT(operation_cid() == kDoubleCid); | 2049 ASSERT(operation_cid() == kDoubleCid); |
2044 return EmitDoubleComparisonOp(compiler, locs(), kind()); | 2050 return EmitDoubleComparisonOp(compiler, locs(), kind()); |
2045 } | 2051 } |
2046 } | 2052 } |
2047 | 2053 |
2048 | 2054 |
2049 EMIT_NATIVE_CODE(RelationalOp, 2, Location::RequiresRegister()) { | 2055 Condition RelationalOpInstr::GetPredictedCondition(FlowGraphCompiler* compiler, |
2050 ASSERT(compiler->is_optimizing()); | 2056 BranchLabels labels) { |
2051 Label is_true, is_false; | 2057 if (operation_cid() == kSmiCid) { |
2052 BranchLabels labels = {&is_true, &is_false, &is_false}; | 2058 return (labels.fall_through != labels.false_label) ? NEXT_IS_FALSE |
2053 const Register result = locs()->out(0).reg(); | 2059 : NEXT_IS_TRUE; |
2054 __ LoadConstant(result, Bool::False()); | 2060 } else { |
2055 Condition true_condition = EmitComparisonCode(compiler, labels); | 2061 ASSERT(operation_cid() == kDoubleCid); |
2056 ASSERT(true_condition == NEXT_IS_TRUE); | 2062 return NEXT_IS_TRUE; |
2057 __ LoadConstant(result, Bool::True()); | 2063 } |
2058 } | 2064 } |
2059 | 2065 |
2060 | 2066 |
2061 void RelationalOpInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 2067 DEFINE_MAKE_LOCATION_SUMMARY(RelationalOp, 2, Location::RequiresRegister()) |
2062 BranchInstr* branch) { | |
2063 BranchLabels labels = compiler->CreateBranchLabels(branch); | |
2064 Condition true_condition = EmitComparisonCode(compiler, labels); | |
2065 EmitBranchOnCondition(compiler, true_condition, labels); | |
2066 } | |
2067 | 2068 |
2068 | 2069 |
2069 EMIT_NATIVE_CODE(CheckArrayBound, 2) { | 2070 EMIT_NATIVE_CODE(CheckArrayBound, 2) { |
2070 const Register length = locs()->in(kLengthPos).reg(); | 2071 const Register length = locs()->in(kLengthPos).reg(); |
2071 const Register index = locs()->in(kIndexPos).reg(); | 2072 const Register index = locs()->in(kIndexPos).reg(); |
2072 const intptr_t index_cid = this->index()->Type()->ToCid(); | 2073 const intptr_t index_cid = this->index()->Type()->ToCid(); |
2073 if (index_cid != kSmiCid) { | 2074 if (index_cid != kSmiCid) { |
2074 __ CheckSmi(index); | 2075 __ CheckSmi(index); |
2075 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, | 2076 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, |
2076 (generalized_ ? ICData::kGeneralized : 0) | | 2077 (generalized_ ? ICData::kGeneralized : 0) | |
2077 (licm_hoisted_ ? ICData::kHoisted : 0)); | 2078 (licm_hoisted_ ? ICData::kHoisted : 0)); |
2078 } | 2079 } |
2079 __ IfULe(length, index); | 2080 __ IfULe(length, index); |
2080 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, | 2081 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, |
2081 (generalized_ ? ICData::kGeneralized : 0) | | 2082 (generalized_ ? ICData::kGeneralized : 0) | |
2082 (licm_hoisted_ ? ICData::kHoisted : 0)); | 2083 (licm_hoisted_ ? ICData::kHoisted : 0)); |
2083 } | 2084 } |
2084 | 2085 |
2085 } // namespace dart | 2086 } // namespace dart |
2086 | 2087 |
2087 #endif // defined TARGET_ARCH_DBC | 2088 #endif // defined TARGET_ARCH_DBC |
OLD | NEW |