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

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