| 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::GetNextInstructionCondition( |
| 487 FlowGraphCompiler* compiler, |
| 488 BranchLabels labels) { |
| 489 return (labels.fall_through == labels.false_label) ? NEXT_IS_TRUE |
| 490 : NEXT_IS_FALSE; |
| 491 } |
| 492 |
| 493 |
| 486 Condition StrictCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler, | 494 Condition StrictCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
| 487 BranchLabels labels) { | 495 BranchLabels labels) { |
| 488 ASSERT((kind() == Token::kNE_STRICT) || (kind() == Token::kEQ_STRICT)); | 496 ASSERT((kind() == Token::kNE_STRICT) || (kind() == Token::kEQ_STRICT)); |
| 489 | 497 |
| 490 Token::Kind comparison; | 498 Token::Kind comparison; |
| 491 Condition condition; | 499 Condition condition; |
| 492 if (labels.fall_through == labels.false_label) { | 500 if (labels.fall_through == labels.false_label) { |
| 493 condition = NEXT_IS_TRUE; | 501 condition = NEXT_IS_TRUE; |
| 494 comparison = kind(); | 502 comparison = kind(); |
| 495 } else { | 503 } else { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 519 if (needs_number_check() && token_pos().IsReal()) { | 527 if (needs_number_check() && token_pos().IsReal()) { |
| 520 compiler->RecordSafepoint(locs()); | 528 compiler->RecordSafepoint(locs()); |
| 521 compiler->AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, deopt_id_, | 529 compiler->AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, deopt_id_, |
| 522 token_pos()); | 530 token_pos()); |
| 523 } | 531 } |
| 524 | 532 |
| 525 return condition; | 533 return condition; |
| 526 } | 534 } |
| 527 | 535 |
| 528 | 536 |
| 529 void StrictCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 537 DEFINE_MAKE_LOCATION_SUMMARY(StrictCompare, |
| 530 BranchInstr* branch) { | 538 2, |
| 531 ASSERT((kind() == Token::kEQ_STRICT) || (kind() == Token::kNE_STRICT)); | 539 Location::RequiresRegister(), |
| 540 needs_number_check() ? LocationSummary::kCall |
| 541 : LocationSummary::kNoCall) |
| 532 | 542 |
| 543 |
| 544 void ComparisonInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
| 545 BranchInstr* branch) { |
| 533 BranchLabels labels = compiler->CreateBranchLabels(branch); | 546 BranchLabels labels = compiler->CreateBranchLabels(branch); |
| 534 Condition true_condition = EmitComparisonCode(compiler, labels); | 547 Condition true_condition = EmitComparisonCode(compiler, labels); |
| 535 EmitBranchOnCondition(compiler, true_condition, labels); | 548 if (true_condition != INVALID_CONDITION) { |
| 549 EmitBranchOnCondition(compiler, true_condition, labels); |
| 550 } |
| 536 } | 551 } |
| 537 | 552 |
| 538 | 553 |
| 539 EMIT_NATIVE_CODE(StrictCompare, | 554 void ComparisonInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 540 2, | |
| 541 Location::RequiresRegister(), | |
| 542 needs_number_check() ? LocationSummary::kCall | |
| 543 : LocationSummary::kNoCall) { | |
| 544 ASSERT((kind() == Token::kEQ_STRICT) || (kind() == Token::kNE_STRICT)); | |
| 545 | |
| 546 Label is_true, is_false; | 555 Label is_true, is_false; |
| 547 BranchLabels labels = {&is_true, &is_false, &is_false}; | 556 BranchLabels labels = {&is_true, &is_false, &is_false}; |
| 548 Condition true_condition = EmitComparisonCode(compiler, labels); | 557 Condition true_condition = |
| 549 EmitBranchOnCondition(compiler, true_condition, labels); | 558 this->GetNextInstructionCondition(compiler, labels); |
| 550 Label done; | 559 if (true_condition == INVALID_CONDITION || !compiler->is_optimizing() || |
| 551 if (compiler->is_optimizing()) { | 560 is_true.IsLinked() || is_false.IsLinked()) { |
| 552 const Register result = locs()->out(0).reg(); | 561 Condition actual_condition = EmitComparisonCode(compiler, labels); |
| 553 __ Bind(&is_false); | 562 ASSERT(actual_condition == true_condition); |
| 554 __ LoadConstant(result, Bool::False()); | 563 if (true_condition != INVALID_CONDITION) { |
| 555 __ Jump(&done); | 564 EmitBranchOnCondition(compiler, true_condition, labels); |
| 556 __ Bind(&is_true); | 565 } |
| 557 __ LoadConstant(result, Bool::True()); | 566 Label done; |
| 558 __ Bind(&done); | |
| 559 } else { | |
| 560 __ Bind(&is_false); | 567 __ Bind(&is_false); |
| 561 __ PushConstant(Bool::False()); | 568 __ PushConstant(Bool::False()); |
| 562 __ Jump(&done); | 569 __ Jump(&done); |
| 563 __ Bind(&is_true); | 570 __ Bind(&is_true); |
| 564 __ PushConstant(Bool::True()); | 571 __ PushConstant(Bool::True()); |
| 565 __ Bind(&done); | 572 __ Bind(&done); |
| 573 } else { |
| 574 const Register result = this->locs()->out(0).reg(); |
| 575 __ LoadConstant( |
| 576 result, true_condition == NEXT_IS_TRUE ? Bool::False() : Bool::True()); |
| 577 Condition actual_condition = EmitComparisonCode(compiler, labels); |
| 578 ASSERT(actual_condition == true_condition); |
| 579 __ LoadConstant( |
| 580 result, true_condition == NEXT_IS_TRUE ? Bool::True() : Bool::False()); |
| 566 } | 581 } |
| 567 } | 582 } |
| 568 | 583 |
| 569 | 584 |
| 570 LocationSummary* BranchInstr::MakeLocationSummary(Zone* zone, bool opt) const { | 585 LocationSummary* BranchInstr::MakeLocationSummary(Zone* zone, bool opt) const { |
| 571 comparison()->InitializeLocationSummary(zone, opt); | 586 comparison()->InitializeLocationSummary(zone, opt); |
| 572 if (!comparison()->HasLocs()) { | 587 if (!comparison()->HasLocs()) { |
| 573 return NULL; | 588 return NULL; |
| 574 } | 589 } |
| 575 // Branches don't produce a result. | 590 // Branches don't produce a result. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 594 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); | 609 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); |
| 595 } | 610 } |
| 596 // We can fall through if the successor is the next block in the list. | 611 // We can fall through if the successor is the next block in the list. |
| 597 // Otherwise, we need a jump. | 612 // Otherwise, we need a jump. |
| 598 if (!compiler->CanFallThroughTo(successor())) { | 613 if (!compiler->CanFallThroughTo(successor())) { |
| 599 __ Jump(compiler->GetJumpLabel(successor())); | 614 __ Jump(compiler->GetJumpLabel(successor())); |
| 600 } | 615 } |
| 601 } | 616 } |
| 602 | 617 |
| 603 | 618 |
| 619 Condition TestSmiInstr::GetNextInstructionCondition(FlowGraphCompiler* compiler, |
| 620 BranchLabels labels) { |
| 621 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); |
| 622 return (kind() == Token::kEQ) ? NEXT_IS_TRUE : NEXT_IS_FALSE; |
| 623 } |
| 624 |
| 625 |
| 604 Condition TestSmiInstr::EmitComparisonCode(FlowGraphCompiler* compiler, | 626 Condition TestSmiInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
| 605 BranchLabels labels) { | 627 BranchLabels labels) { |
| 606 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); | 628 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); |
| 607 Register left = locs()->in(0).reg(); | 629 Register left = locs()->in(0).reg(); |
| 608 Register right = locs()->in(1).reg(); | 630 Register right = locs()->in(1).reg(); |
| 609 __ TestSmi(left, right); | 631 __ TestSmi(left, right); |
| 610 return (kind() == Token::kEQ) ? NEXT_IS_TRUE : NEXT_IS_FALSE; | 632 return (kind() == Token::kEQ) ? NEXT_IS_TRUE : NEXT_IS_FALSE; |
| 611 } | 633 } |
| 612 | 634 |
| 613 | 635 |
| 614 void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 636 DEFINE_MAKE_LOCATION_SUMMARY(TestSmi, |
| 615 BranchInstr* branch) { | 637 2, |
| 616 BranchLabels labels = compiler->CreateBranchLabels(branch); | 638 Location::RequiresRegister(), |
| 617 Condition true_condition = EmitComparisonCode(compiler, labels); | 639 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 | 640 |
| 630 | 641 |
| 631 Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler, | 642 Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
| 632 BranchLabels labels) { | 643 BranchLabels labels) { |
| 633 ASSERT((kind() == Token::kIS) || (kind() == Token::kISNOT)); | 644 ASSERT((kind() == Token::kIS) || (kind() == Token::kISNOT)); |
| 634 const Register value = locs()->in(0).reg(); | 645 const Register value = locs()->in(0).reg(); |
| 635 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0; | 646 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0; |
| 636 | 647 |
| 637 const ZoneGrowableArray<intptr_t>& data = cid_results(); | 648 const ZoneGrowableArray<intptr_t>& data = cid_results(); |
| 638 const intptr_t num_cases = data.length() / 2; | 649 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 | 666 // that are in the list. These must be all the same (see asserts in the |
| 656 // constructor). | 667 // constructor). |
| 657 Label* target = result ? labels.false_label : labels.true_label; | 668 Label* target = result ? labels.false_label : labels.true_label; |
| 658 __ Jump(target); | 669 __ Jump(target); |
| 659 } | 670 } |
| 660 | 671 |
| 661 return NEXT_IS_TRUE; | 672 return NEXT_IS_TRUE; |
| 662 } | 673 } |
| 663 | 674 |
| 664 | 675 |
| 665 void TestCidsInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 676 Condition TestCidsInstr::GetNextInstructionCondition( |
| 666 BranchInstr* branch) { | 677 FlowGraphCompiler* compiler, |
| 667 BranchLabels labels = compiler->CreateBranchLabels(branch); | 678 BranchLabels labels) { |
| 668 Condition true_condition = EmitComparisonCode(compiler, labels); | 679 return NEXT_IS_TRUE; |
| 669 EmitBranchOnCondition(compiler, true_condition, labels); | |
| 670 } | 680 } |
| 671 | 681 |
| 672 | 682 |
| 673 EMIT_NATIVE_CODE(TestCids, | 683 DEFINE_MAKE_LOCATION_SUMMARY(TestCids, |
| 674 1, | 684 1, |
| 675 Location::RequiresRegister(), | 685 Location::RequiresRegister(), |
| 676 LocationSummary::kNoCall) { | 686 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 | 687 |
| 690 | 688 |
| 691 EMIT_NATIVE_CODE(CreateArray, | 689 EMIT_NATIVE_CODE(CreateArray, |
| 692 2, | 690 2, |
| 693 Location::RequiresRegister(), | 691 Location::RequiresRegister(), |
| 694 LocationSummary::kCall) { | 692 LocationSummary::kCall) { |
| 695 if (compiler->is_optimizing()) { | 693 if (compiler->is_optimizing()) { |
| 696 const Register length = locs()->in(kLengthPos).reg(); | 694 const Register length = locs()->in(kLengthPos).reg(); |
| 697 const Register type_arguments = locs()->in(kElementTypePos).reg(); | 695 const Register type_arguments = locs()->in(kElementTypePos).reg(); |
| 698 const Register out = locs()->out(0).reg(); | 696 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); | 1744 __ DDiv(result, left, right); |
| 1747 break; | 1745 break; |
| 1748 default: | 1746 default: |
| 1749 UNREACHABLE(); | 1747 UNREACHABLE(); |
| 1750 } | 1748 } |
| 1751 } | 1749 } |
| 1752 | 1750 |
| 1753 | 1751 |
| 1754 Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, | 1752 Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
| 1755 BranchLabels labels) { | 1753 BranchLabels labels) { |
| 1756 UNREACHABLE(); | |
| 1757 return Condition(); | |
| 1758 } | |
| 1759 | |
| 1760 | |
| 1761 void DoubleTestOpInstr::EmitBranchCode(FlowGraphCompiler* compiler, | |
| 1762 BranchInstr* branch) { | |
| 1763 ASSERT(compiler->is_optimizing()); | 1754 ASSERT(compiler->is_optimizing()); |
| 1764 BranchLabels labels = compiler->CreateBranchLabels(branch); | |
| 1765 const Register value = locs()->in(0).reg(); | 1755 const Register value = locs()->in(0).reg(); |
| 1766 switch (op_kind()) { | 1756 switch (op_kind()) { |
| 1767 case MethodRecognizer::kDouble_getIsNaN: | 1757 case MethodRecognizer::kDouble_getIsNaN: |
| 1768 __ DoubleIsNaN(value); | 1758 __ DoubleIsNaN(value); |
| 1769 break; | 1759 break; |
| 1770 case MethodRecognizer::kDouble_getIsInfinite: | 1760 case MethodRecognizer::kDouble_getIsInfinite: |
| 1771 __ DoubleIsInfinite(value); | 1761 __ DoubleIsInfinite(value); |
| 1772 break; | 1762 break; |
| 1773 default: | 1763 default: |
| 1774 UNREACHABLE(); | 1764 UNREACHABLE(); |
| 1775 } | 1765 } |
| 1776 const bool is_negated = kind() != Token::kEQ; | 1766 const bool is_negated = kind() != Token::kEQ; |
| 1777 EmitBranchOnCondition(compiler, is_negated ? NEXT_IS_FALSE : NEXT_IS_TRUE, | 1767 return is_negated ? NEXT_IS_FALSE : NEXT_IS_TRUE; |
| 1778 labels); | |
| 1779 } | 1768 } |
| 1780 | 1769 |
| 1781 | 1770 |
| 1782 EMIT_NATIVE_CODE(DoubleTestOp, 1, Location::RequiresRegister()) { | 1771 Condition DoubleTestOpInstr::GetNextInstructionCondition( |
| 1783 ASSERT(compiler->is_optimizing()); | 1772 FlowGraphCompiler* compiler, |
| 1784 const Register value = locs()->in(0).reg(); | 1773 BranchLabels labels) { |
| 1785 const Register result = locs()->out(0).reg(); | |
| 1786 const bool is_negated = kind() != Token::kEQ; | 1774 const bool is_negated = kind() != Token::kEQ; |
| 1787 __ LoadConstant(result, is_negated ? Bool::True() : Bool::False()); | 1775 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 } | 1776 } |
| 1800 | 1777 |
| 1801 | 1778 |
| 1779 DEFINE_MAKE_LOCATION_SUMMARY(DoubleTestOp, 1, Location::RequiresRegister()) |
| 1780 |
| 1781 |
| 1802 EMIT_NATIVE_CODE(UnaryDoubleOp, 1, Location::RequiresRegister()) { | 1782 EMIT_NATIVE_CODE(UnaryDoubleOp, 1, Location::RequiresRegister()) { |
| 1803 const Register value = locs()->in(0).reg(); | 1783 const Register value = locs()->in(0).reg(); |
| 1804 const Register result = locs()->out(0).reg(); | 1784 const Register result = locs()->out(0).reg(); |
| 1805 __ DNeg(result, value); | 1785 __ DNeg(result, value); |
| 1806 } | 1786 } |
| 1807 | 1787 |
| 1808 | 1788 |
| 1809 EMIT_NATIVE_CODE(MathUnary, 1, Location::RequiresRegister()) { | 1789 EMIT_NATIVE_CODE(MathUnary, 1, Location::RequiresRegister()) { |
| 1810 const Register value = locs()->in(0).reg(); | 1790 const Register value = locs()->in(0).reg(); |
| 1811 const Register result = locs()->out(0).reg(); | 1791 const Register result = locs()->out(0).reg(); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 Token::Kind kind, | 1946 Token::Kind kind, |
| 1967 BranchLabels labels) { | 1947 BranchLabels labels) { |
| 1968 const Register left = locs->in(0).reg(); | 1948 const Register left = locs->in(0).reg(); |
| 1969 const Register right = locs->in(1).reg(); | 1949 const Register right = locs->in(1).reg(); |
| 1970 Token::Kind comparison = kind; | 1950 Token::Kind comparison = kind; |
| 1971 Condition condition = NEXT_IS_TRUE; | 1951 Condition condition = NEXT_IS_TRUE; |
| 1972 if (labels.fall_through != labels.false_label) { | 1952 if (labels.fall_through != labels.false_label) { |
| 1973 // If we aren't falling through to the false label, we can save a Jump | 1953 // 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 | 1954 // 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 | 1955 // flipping the sense of the test such that the instruction following the |
| 1976 // test is the Jump to the false label. | 1956 // test is the Jump to the false label. In the case where both labels are |
| 1957 // null we don't flip the sense of the test. |
| 1977 condition = NEXT_IS_FALSE; | 1958 condition = NEXT_IS_FALSE; |
| 1978 comparison = FlipCondition(kind); | 1959 comparison = FlipCondition(kind); |
| 1979 } | 1960 } |
| 1980 __ Emit(Bytecode::Encode(OpcodeForSmiCondition(comparison), left, right)); | 1961 __ Emit(Bytecode::Encode(OpcodeForSmiCondition(comparison), left, right)); |
| 1981 return condition; | 1962 return condition; |
| 1982 } | 1963 } |
| 1983 | 1964 |
| 1984 | 1965 |
| 1985 static Condition EmitDoubleComparisonOp(FlowGraphCompiler* compiler, | 1966 static Condition EmitDoubleComparisonOp(FlowGraphCompiler* compiler, |
| 1986 LocationSummary* locs, | 1967 LocationSummary* locs, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2003 BranchLabels labels) { | 1984 BranchLabels labels) { |
| 2004 if (operation_cid() == kSmiCid) { | 1985 if (operation_cid() == kSmiCid) { |
| 2005 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); | 1986 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); |
| 2006 } else { | 1987 } else { |
| 2007 ASSERT(operation_cid() == kDoubleCid); | 1988 ASSERT(operation_cid() == kDoubleCid); |
| 2008 return EmitDoubleComparisonOp(compiler, locs(), kind()); | 1989 return EmitDoubleComparisonOp(compiler, locs(), kind()); |
| 2009 } | 1990 } |
| 2010 } | 1991 } |
| 2011 | 1992 |
| 2012 | 1993 |
| 2013 EMIT_NATIVE_CODE(EqualityCompare, 2, Location::RequiresRegister()) { | 1994 Condition EqualityCompareInstr::GetNextInstructionCondition( |
| 2014 ASSERT(compiler->is_optimizing()); | 1995 FlowGraphCompiler* compiler, |
| 2015 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); | 1996 BranchLabels labels) { |
| 2016 Label is_true, is_false; | 1997 if (operation_cid() == kSmiCid) { |
| 2017 // These labels are not used. They are arranged so that EmitComparisonCode | 1998 return (labels.fall_through != labels.false_label) ? NEXT_IS_FALSE |
| 2018 // emits a test that executes the following instruction when the test | 1999 : NEXT_IS_TRUE; |
| 2019 // succeeds. | 2000 } else { |
| 2020 BranchLabels labels = {&is_true, &is_false, &is_false}; | 2001 ASSERT(operation_cid() == kDoubleCid); |
| 2021 const Register result = locs()->out(0).reg(); | 2002 return NEXT_IS_TRUE; |
| 2022 __ LoadConstant(result, Bool::False()); | 2003 } |
| 2023 Condition true_condition = EmitComparisonCode(compiler, labels); | |
| 2024 ASSERT(true_condition == NEXT_IS_TRUE); | |
| 2025 __ LoadConstant(result, Bool::True()); | |
| 2026 } | 2004 } |
| 2027 | 2005 |
| 2028 | 2006 |
| 2029 void EqualityCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 2007 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 | 2008 |
| 2037 | 2009 |
| 2038 Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, | 2010 Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
| 2039 BranchLabels labels) { | 2011 BranchLabels labels) { |
| 2040 if (operation_cid() == kSmiCid) { | 2012 if (operation_cid() == kSmiCid) { |
| 2041 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); | 2013 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); |
| 2042 } else { | 2014 } else { |
| 2043 ASSERT(operation_cid() == kDoubleCid); | 2015 ASSERT(operation_cid() == kDoubleCid); |
| 2044 return EmitDoubleComparisonOp(compiler, locs(), kind()); | 2016 return EmitDoubleComparisonOp(compiler, locs(), kind()); |
| 2045 } | 2017 } |
| 2046 } | 2018 } |
| 2047 | 2019 |
| 2048 | 2020 |
| 2049 EMIT_NATIVE_CODE(RelationalOp, 2, Location::RequiresRegister()) { | 2021 Condition RelationalOpInstr::GetNextInstructionCondition( |
| 2050 ASSERT(compiler->is_optimizing()); | 2022 FlowGraphCompiler* compiler, |
| 2051 Label is_true, is_false; | 2023 BranchLabels labels) { |
| 2052 BranchLabels labels = {&is_true, &is_false, &is_false}; | 2024 if (operation_cid() == kSmiCid) { |
| 2053 const Register result = locs()->out(0).reg(); | 2025 return (labels.fall_through != labels.false_label) ? NEXT_IS_FALSE |
| 2054 __ LoadConstant(result, Bool::False()); | 2026 : NEXT_IS_TRUE; |
| 2055 Condition true_condition = EmitComparisonCode(compiler, labels); | 2027 } else { |
| 2056 ASSERT(true_condition == NEXT_IS_TRUE); | 2028 ASSERT(operation_cid() == kDoubleCid); |
| 2057 __ LoadConstant(result, Bool::True()); | 2029 return NEXT_IS_TRUE; |
| 2030 } |
| 2058 } | 2031 } |
| 2059 | 2032 |
| 2060 | 2033 |
| 2061 void RelationalOpInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 2034 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 | 2035 |
| 2068 | 2036 |
| 2069 EMIT_NATIVE_CODE(CheckArrayBound, 2) { | 2037 EMIT_NATIVE_CODE(CheckArrayBound, 2) { |
| 2070 const Register length = locs()->in(kLengthPos).reg(); | 2038 const Register length = locs()->in(kLengthPos).reg(); |
| 2071 const Register index = locs()->in(kIndexPos).reg(); | 2039 const Register index = locs()->in(kIndexPos).reg(); |
| 2072 const intptr_t index_cid = this->index()->Type()->ToCid(); | 2040 const intptr_t index_cid = this->index()->Type()->ToCid(); |
| 2073 if (index_cid != kSmiCid) { | 2041 if (index_cid != kSmiCid) { |
| 2074 __ CheckSmi(index); | 2042 __ CheckSmi(index); |
| 2075 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, | 2043 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, |
| 2076 (generalized_ ? ICData::kGeneralized : 0) | | 2044 (generalized_ ? ICData::kGeneralized : 0) | |
| 2077 (licm_hoisted_ ? ICData::kHoisted : 0)); | 2045 (licm_hoisted_ ? ICData::kHoisted : 0)); |
| 2078 } | 2046 } |
| 2079 __ IfULe(length, index); | 2047 __ IfULe(length, index); |
| 2080 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, | 2048 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, |
| 2081 (generalized_ ? ICData::kGeneralized : 0) | | 2049 (generalized_ ? ICData::kGeneralized : 0) | |
| 2082 (licm_hoisted_ ? ICData::kHoisted : 0)); | 2050 (licm_hoisted_ ? ICData::kHoisted : 0)); |
| 2083 } | 2051 } |
| 2084 | 2052 |
| 2085 } // namespace dart | 2053 } // namespace dart |
| 2086 | 2054 |
| 2087 #endif // defined TARGET_ARCH_DBC | 2055 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |