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

Side by Side Diff: runtime/vm/intermediate_language_dbc.cc

Issue 2947633002: VM-codegen: Clean up the way we emit code for comparison instructions. (Closed)
Patch Set: Simplify DBC ComparisonInstr::EmitNativeCode Created 3 years, 6 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 | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 bool next_is_true = true_condition == NEXT_IS_TRUE;
576 __ LoadConstant(result, Bool::Get(!next_is_true));
577 Condition actual_condition = EmitComparisonCode(compiler, labels);
578 ASSERT(actual_condition == true_condition);
579 // Although we have a condition to branch on, the comparison code may also
580 // have contained a direct branch to one of the labels, so they may need to
581 // be bound.
582 if (next_is_true && is_true.IsLinked()) {
583 __ Bind(&is_true);
584 } else if (!next_is_true && is_false.IsLinked()) {
585 __ Bind(&is_false);
586 }
587 // This instruction is conditionally skipped by EmitComparisonCode.
588 __ LoadConstant(result, Bool::Get(next_is_true));
589 // If the other label is linked we need to bind it and emit code that loads
590 // the correct boolean.
591 if ((next_is_true && is_false.IsLinked()) ||
592 (!next_is_true && is_true.IsLinked())) {
593 Label done;
594 __ Jump(&done);
595 __ Bind(next_is_true ? &is_false : &is_true);
596 __ LoadConstant(result, Bool::Get(!next_is_true));
597 __ Bind(&done);
598 }
566 } 599 }
567 } 600 }
568 601
569 602
570 LocationSummary* BranchInstr::MakeLocationSummary(Zone* zone, bool opt) const { 603 LocationSummary* BranchInstr::MakeLocationSummary(Zone* zone, bool opt) const {
571 comparison()->InitializeLocationSummary(zone, opt); 604 comparison()->InitializeLocationSummary(zone, opt);
572 if (!comparison()->HasLocs()) { 605 if (!comparison()->HasLocs()) {
573 return NULL; 606 return NULL;
574 } 607 }
575 // Branches don't produce a result. 608 // Branches don't produce a result.
(...skipping 18 matching lines...) Expand all
594 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); 627 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
595 } 628 }
596 // We can fall through if the successor is the next block in the list. 629 // We can fall through if the successor is the next block in the list.
597 // Otherwise, we need a jump. 630 // Otherwise, we need a jump.
598 if (!compiler->CanFallThroughTo(successor())) { 631 if (!compiler->CanFallThroughTo(successor())) {
599 __ Jump(compiler->GetJumpLabel(successor())); 632 __ Jump(compiler->GetJumpLabel(successor()));
600 } 633 }
601 } 634 }
602 635
603 636
637 Condition TestSmiInstr::GetNextInstructionCondition(FlowGraphCompiler* compiler,
638 BranchLabels labels) {
639 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE));
640 return (kind() == Token::kEQ) ? NEXT_IS_TRUE : NEXT_IS_FALSE;
641 }
642
643
604 Condition TestSmiInstr::EmitComparisonCode(FlowGraphCompiler* compiler, 644 Condition TestSmiInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
605 BranchLabels labels) { 645 BranchLabels labels) {
606 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); 646 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE));
607 Register left = locs()->in(0).reg(); 647 Register left = locs()->in(0).reg();
608 Register right = locs()->in(1).reg(); 648 Register right = locs()->in(1).reg();
609 __ TestSmi(left, right); 649 __ TestSmi(left, right);
610 return (kind() == Token::kEQ) ? NEXT_IS_TRUE : NEXT_IS_FALSE; 650 return (kind() == Token::kEQ) ? NEXT_IS_TRUE : NEXT_IS_FALSE;
611 } 651 }
612 652
613 653
614 void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler, 654 DEFINE_MAKE_LOCATION_SUMMARY(TestSmi,
615 BranchInstr* branch) { 655 2,
616 BranchLabels labels = compiler->CreateBranchLabels(branch); 656 Location::RequiresRegister(),
617 Condition true_condition = EmitComparisonCode(compiler, labels); 657 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 658
630 659
631 Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler, 660 Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
632 BranchLabels labels) { 661 BranchLabels labels) {
633 ASSERT((kind() == Token::kIS) || (kind() == Token::kISNOT)); 662 ASSERT((kind() == Token::kIS) || (kind() == Token::kISNOT));
634 const Register value = locs()->in(0).reg(); 663 const Register value = locs()->in(0).reg();
635 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0; 664 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0;
636 665
637 const ZoneGrowableArray<intptr_t>& data = cid_results(); 666 const ZoneGrowableArray<intptr_t>& data = cid_results();
638 const intptr_t num_cases = data.length() / 2; 667 const intptr_t num_cases = data.length() / 2;
(...skipping 16 matching lines...) Expand all
655 // that are in the list. These must be all the same (see asserts in the 684 // that are in the list. These must be all the same (see asserts in the
656 // constructor). 685 // constructor).
657 Label* target = result ? labels.false_label : labels.true_label; 686 Label* target = result ? labels.false_label : labels.true_label;
658 __ Jump(target); 687 __ Jump(target);
659 } 688 }
660 689
661 return NEXT_IS_TRUE; 690 return NEXT_IS_TRUE;
662 } 691 }
663 692
664 693
665 void TestCidsInstr::EmitBranchCode(FlowGraphCompiler* compiler, 694 Condition TestCidsInstr::GetNextInstructionCondition(
666 BranchInstr* branch) { 695 FlowGraphCompiler* compiler,
667 BranchLabels labels = compiler->CreateBranchLabels(branch); 696 BranchLabels labels) {
668 Condition true_condition = EmitComparisonCode(compiler, labels); 697 return NEXT_IS_TRUE;
669 EmitBranchOnCondition(compiler, true_condition, labels);
670 } 698 }
671 699
672 700
673 EMIT_NATIVE_CODE(TestCids, 701 DEFINE_MAKE_LOCATION_SUMMARY(TestCids,
674 1, 702 1,
675 Location::RequiresRegister(), 703 Location::RequiresRegister(),
676 LocationSummary::kNoCall) { 704 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 705
690 706
691 EMIT_NATIVE_CODE(CreateArray, 707 EMIT_NATIVE_CODE(CreateArray,
692 2, 708 2,
693 Location::RequiresRegister(), 709 Location::RequiresRegister(),
694 LocationSummary::kCall) { 710 LocationSummary::kCall) {
695 if (compiler->is_optimizing()) { 711 if (compiler->is_optimizing()) {
696 const Register length = locs()->in(kLengthPos).reg(); 712 const Register length = locs()->in(kLengthPos).reg();
697 const Register type_arguments = locs()->in(kElementTypePos).reg(); 713 const Register type_arguments = locs()->in(kElementTypePos).reg();
698 const Register out = locs()->out(0).reg(); 714 const Register out = locs()->out(0).reg();
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 __ DDiv(result, left, right); 1762 __ DDiv(result, left, right);
1747 break; 1763 break;
1748 default: 1764 default:
1749 UNREACHABLE(); 1765 UNREACHABLE();
1750 } 1766 }
1751 } 1767 }
1752 1768
1753 1769
1754 Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, 1770 Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
1755 BranchLabels labels) { 1771 BranchLabels labels) {
1756 UNREACHABLE();
1757 return Condition();
1758 }
1759
1760
1761 void DoubleTestOpInstr::EmitBranchCode(FlowGraphCompiler* compiler,
1762 BranchInstr* branch) {
1763 ASSERT(compiler->is_optimizing()); 1772 ASSERT(compiler->is_optimizing());
1764 BranchLabels labels = compiler->CreateBranchLabels(branch);
1765 const Register value = locs()->in(0).reg(); 1773 const Register value = locs()->in(0).reg();
1766 switch (op_kind()) { 1774 switch (op_kind()) {
1767 case MethodRecognizer::kDouble_getIsNaN: 1775 case MethodRecognizer::kDouble_getIsNaN:
1768 __ DoubleIsNaN(value); 1776 __ DoubleIsNaN(value);
1769 break; 1777 break;
1770 case MethodRecognizer::kDouble_getIsInfinite: 1778 case MethodRecognizer::kDouble_getIsInfinite:
1771 __ DoubleIsInfinite(value); 1779 __ DoubleIsInfinite(value);
1772 break; 1780 break;
1773 default: 1781 default:
1774 UNREACHABLE(); 1782 UNREACHABLE();
1775 } 1783 }
1776 const bool is_negated = kind() != Token::kEQ; 1784 const bool is_negated = kind() != Token::kEQ;
1777 EmitBranchOnCondition(compiler, is_negated ? NEXT_IS_FALSE : NEXT_IS_TRUE, 1785 return is_negated ? NEXT_IS_FALSE : NEXT_IS_TRUE;
1778 labels);
1779 } 1786 }
1780 1787
1781 1788
1782 EMIT_NATIVE_CODE(DoubleTestOp, 1, Location::RequiresRegister()) { 1789 Condition DoubleTestOpInstr::GetNextInstructionCondition(
1783 ASSERT(compiler->is_optimizing()); 1790 FlowGraphCompiler* compiler,
1784 const Register value = locs()->in(0).reg(); 1791 BranchLabels labels) {
1785 const Register result = locs()->out(0).reg();
1786 const bool is_negated = kind() != Token::kEQ; 1792 const bool is_negated = kind() != Token::kEQ;
1787 __ LoadConstant(result, is_negated ? Bool::True() : Bool::False()); 1793 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 } 1794 }
1800 1795
1801 1796
1797 DEFINE_MAKE_LOCATION_SUMMARY(DoubleTestOp, 1, Location::RequiresRegister())
1798
1799
1802 EMIT_NATIVE_CODE(UnaryDoubleOp, 1, Location::RequiresRegister()) { 1800 EMIT_NATIVE_CODE(UnaryDoubleOp, 1, Location::RequiresRegister()) {
1803 const Register value = locs()->in(0).reg(); 1801 const Register value = locs()->in(0).reg();
1804 const Register result = locs()->out(0).reg(); 1802 const Register result = locs()->out(0).reg();
1805 __ DNeg(result, value); 1803 __ DNeg(result, value);
1806 } 1804 }
1807 1805
1808 1806
1809 EMIT_NATIVE_CODE(MathUnary, 1, Location::RequiresRegister()) { 1807 EMIT_NATIVE_CODE(MathUnary, 1, Location::RequiresRegister()) {
1810 const Register value = locs()->in(0).reg(); 1808 const Register value = locs()->in(0).reg();
1811 const Register result = locs()->out(0).reg(); 1809 const Register result = locs()->out(0).reg();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 Token::Kind kind, 1964 Token::Kind kind,
1967 BranchLabels labels) { 1965 BranchLabels labels) {
1968 const Register left = locs->in(0).reg(); 1966 const Register left = locs->in(0).reg();
1969 const Register right = locs->in(1).reg(); 1967 const Register right = locs->in(1).reg();
1970 Token::Kind comparison = kind; 1968 Token::Kind comparison = kind;
1971 Condition condition = NEXT_IS_TRUE; 1969 Condition condition = NEXT_IS_TRUE;
1972 if (labels.fall_through != labels.false_label) { 1970 if (labels.fall_through != labels.false_label) {
1973 // If we aren't falling through to the false label, we can save a Jump 1971 // 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 1972 // 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 1973 // flipping the sense of the test such that the instruction following the
1976 // test is the Jump to the false label. 1974 // test is the Jump to the false label. In the case where both labels are
1975 // null we don't flip the sense of the test.
1977 condition = NEXT_IS_FALSE; 1976 condition = NEXT_IS_FALSE;
1978 comparison = FlipCondition(kind); 1977 comparison = FlipCondition(kind);
1979 } 1978 }
1980 __ Emit(Bytecode::Encode(OpcodeForSmiCondition(comparison), left, right)); 1979 __ Emit(Bytecode::Encode(OpcodeForSmiCondition(comparison), left, right));
1981 return condition; 1980 return condition;
1982 } 1981 }
1983 1982
1984 1983
1985 static Condition EmitDoubleComparisonOp(FlowGraphCompiler* compiler, 1984 static Condition EmitDoubleComparisonOp(FlowGraphCompiler* compiler,
1986 LocationSummary* locs, 1985 LocationSummary* locs,
(...skipping 16 matching lines...) Expand all
2003 BranchLabels labels) { 2002 BranchLabels labels) {
2004 if (operation_cid() == kSmiCid) { 2003 if (operation_cid() == kSmiCid) {
2005 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); 2004 return EmitSmiComparisonOp(compiler, locs(), kind(), labels);
2006 } else { 2005 } else {
2007 ASSERT(operation_cid() == kDoubleCid); 2006 ASSERT(operation_cid() == kDoubleCid);
2008 return EmitDoubleComparisonOp(compiler, locs(), kind()); 2007 return EmitDoubleComparisonOp(compiler, locs(), kind());
2009 } 2008 }
2010 } 2009 }
2011 2010
2012 2011
2013 EMIT_NATIVE_CODE(EqualityCompare, 2, Location::RequiresRegister()) { 2012 Condition EqualityCompareInstr::GetNextInstructionCondition(
2014 ASSERT(compiler->is_optimizing()); 2013 FlowGraphCompiler* compiler,
2015 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); 2014 BranchLabels labels) {
2016 Label is_true, is_false; 2015 if (operation_cid() == kSmiCid) {
2017 // These labels are not used. They are arranged so that EmitComparisonCode 2016 return (labels.fall_through != labels.false_label) ? NEXT_IS_FALSE
2018 // emits a test that executes the following instruction when the test 2017 : NEXT_IS_TRUE;
2019 // succeeds. 2018 } else {
2020 BranchLabels labels = {&is_true, &is_false, &is_false}; 2019 ASSERT(operation_cid() == kDoubleCid);
2021 const Register result = locs()->out(0).reg(); 2020 return NEXT_IS_TRUE;
2022 __ LoadConstant(result, Bool::False()); 2021 }
2023 Condition true_condition = EmitComparisonCode(compiler, labels);
2024 ASSERT(true_condition == NEXT_IS_TRUE);
2025 __ LoadConstant(result, Bool::True());
2026 } 2022 }
2027 2023
2028 2024
2029 void EqualityCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, 2025 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 2026
2037 2027
2038 Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, 2028 Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
2039 BranchLabels labels) { 2029 BranchLabels labels) {
2040 if (operation_cid() == kSmiCid) { 2030 if (operation_cid() == kSmiCid) {
2041 return EmitSmiComparisonOp(compiler, locs(), kind(), labels); 2031 return EmitSmiComparisonOp(compiler, locs(), kind(), labels);
2042 } else { 2032 } else {
2043 ASSERT(operation_cid() == kDoubleCid); 2033 ASSERT(operation_cid() == kDoubleCid);
2044 return EmitDoubleComparisonOp(compiler, locs(), kind()); 2034 return EmitDoubleComparisonOp(compiler, locs(), kind());
2045 } 2035 }
2046 } 2036 }
2047 2037
2048 2038
2049 EMIT_NATIVE_CODE(RelationalOp, 2, Location::RequiresRegister()) { 2039 Condition RelationalOpInstr::GetNextInstructionCondition(
2050 ASSERT(compiler->is_optimizing()); 2040 FlowGraphCompiler* compiler,
2051 Label is_true, is_false; 2041 BranchLabels labels) {
2052 BranchLabels labels = {&is_true, &is_false, &is_false}; 2042 if (operation_cid() == kSmiCid) {
2053 const Register result = locs()->out(0).reg(); 2043 return (labels.fall_through != labels.false_label) ? NEXT_IS_FALSE
2054 __ LoadConstant(result, Bool::False()); 2044 : NEXT_IS_TRUE;
2055 Condition true_condition = EmitComparisonCode(compiler, labels); 2045 } else {
2056 ASSERT(true_condition == NEXT_IS_TRUE); 2046 ASSERT(operation_cid() == kDoubleCid);
2057 __ LoadConstant(result, Bool::True()); 2047 return NEXT_IS_TRUE;
2048 }
2058 } 2049 }
2059 2050
2060 2051
2061 void RelationalOpInstr::EmitBranchCode(FlowGraphCompiler* compiler, 2052 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 2053
2068 2054
2069 EMIT_NATIVE_CODE(CheckArrayBound, 2) { 2055 EMIT_NATIVE_CODE(CheckArrayBound, 2) {
2070 const Register length = locs()->in(kLengthPos).reg(); 2056 const Register length = locs()->in(kLengthPos).reg();
2071 const Register index = locs()->in(kIndexPos).reg(); 2057 const Register index = locs()->in(kIndexPos).reg();
2072 const intptr_t index_cid = this->index()->Type()->ToCid(); 2058 const intptr_t index_cid = this->index()->Type()->ToCid();
2073 if (index_cid != kSmiCid) { 2059 if (index_cid != kSmiCid) {
2074 __ CheckSmi(index); 2060 __ CheckSmi(index);
2075 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, 2061 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound,
2076 (generalized_ ? ICData::kGeneralized : 0) | 2062 (generalized_ ? ICData::kGeneralized : 0) |
2077 (licm_hoisted_ ? ICData::kHoisted : 0)); 2063 (licm_hoisted_ ? ICData::kHoisted : 0));
2078 } 2064 }
2079 __ IfULe(length, index); 2065 __ IfULe(length, index);
2080 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, 2066 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound,
2081 (generalized_ ? ICData::kGeneralized : 0) | 2067 (generalized_ ? ICData::kGeneralized : 0) |
2082 (licm_hoisted_ ? ICData::kHoisted : 0)); 2068 (licm_hoisted_ ? ICData::kHoisted : 0));
2083 } 2069 }
2084 2070
2085 } // namespace dart 2071 } // namespace dart
2086 2072
2087 #endif // defined TARGET_ARCH_DBC 2073 #endif // defined TARGET_ARCH_DBC
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698