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

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

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