| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 __ pushq(right); | 562 __ pushq(right); |
| 563 EmitEqualityAsPolymorphicCall(compiler, ic_data, locs, branch, kind, | 563 EmitEqualityAsPolymorphicCall(compiler, ic_data, locs, branch, kind, |
| 564 deopt_id, token_pos); | 564 deopt_id, token_pos); |
| 565 __ Bind(&done); | 565 __ Bind(&done); |
| 566 } | 566 } |
| 567 | 567 |
| 568 | 568 |
| 569 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, | 569 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, |
| 570 const LocationSummary& locs, | 570 const LocationSummary& locs, |
| 571 Token::Kind kind, | 571 Token::Kind kind, |
| 572 BranchInstr* branch, | 572 BranchInstr* branch) { |
| 573 intptr_t deopt_id) { | |
| 574 Register left = locs.in(0).reg(); | 573 Register left = locs.in(0).reg(); |
| 575 Register right = locs.in(1).reg(); | 574 Register right = locs.in(1).reg(); |
| 576 | 575 |
| 577 Condition true_condition = TokenKindToSmiCondition(kind); | 576 Condition true_condition = TokenKindToSmiCondition(kind); |
| 578 __ cmpq(left, right); | 577 __ cmpq(left, right); |
| 579 | 578 |
| 580 if (branch != NULL) { | 579 if (branch != NULL) { |
| 581 branch->EmitBranchOnCondition(compiler, true_condition); | 580 branch->EmitBranchOnCondition(compiler, true_condition); |
| 582 } else { | 581 } else { |
| 583 Register result = locs.out().reg(); | 582 Register result = locs.out().reg(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 true_condition, left, right, locs.out().reg()); | 622 true_condition, left, right, locs.out().reg()); |
| 624 } | 623 } |
| 625 } | 624 } |
| 626 | 625 |
| 627 | 626 |
| 628 void EqualityCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 627 void EqualityCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 629 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); | 628 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); |
| 630 BranchInstr* kNoBranch = NULL; | 629 BranchInstr* kNoBranch = NULL; |
| 631 if (receiver_class_id() == kSmiCid) { | 630 if (receiver_class_id() == kSmiCid) { |
| 632 // Deoptimizes if both arguments not Smi. | 631 // Deoptimizes if both arguments not Smi. |
| 633 EmitSmiComparisonOp(compiler, *locs(), kind(), kNoBranch, deopt_id()); | 632 EmitSmiComparisonOp(compiler, *locs(), kind(), kNoBranch); |
| 634 return; | 633 return; |
| 635 } | 634 } |
| 636 if (receiver_class_id() == kDoubleCid) { | 635 if (receiver_class_id() == kDoubleCid) { |
| 637 // Deoptimizes if both arguments are Smi, or if none is Double or Smi. | 636 // Deoptimizes if both arguments are Smi, or if none is Double or Smi. |
| 638 EmitDoubleComparisonOp(compiler, *locs(), kind(), kNoBranch); | 637 EmitDoubleComparisonOp(compiler, *locs(), kind(), kNoBranch); |
| 639 return; | 638 return; |
| 640 } | 639 } |
| 641 const bool is_checked_strict_equal = | 640 const bool is_checked_strict_equal = |
| 642 HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid); | 641 HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid); |
| 643 if (is_checked_strict_equal) { | 642 if (is_checked_strict_equal) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 661 locs()); | 660 locs()); |
| 662 ASSERT(locs()->out().reg() == RAX); | 661 ASSERT(locs()->out().reg() == RAX); |
| 663 } | 662 } |
| 664 | 663 |
| 665 | 664 |
| 666 void EqualityCompareComp::EmitBranchCode(FlowGraphCompiler* compiler, | 665 void EqualityCompareComp::EmitBranchCode(FlowGraphCompiler* compiler, |
| 667 BranchInstr* branch) { | 666 BranchInstr* branch) { |
| 668 ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ)); | 667 ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ)); |
| 669 if (receiver_class_id() == kSmiCid) { | 668 if (receiver_class_id() == kSmiCid) { |
| 670 // Deoptimizes if both arguments not Smi. | 669 // Deoptimizes if both arguments not Smi. |
| 671 EmitSmiComparisonOp(compiler, *locs(), kind(), branch, deopt_id()); | 670 EmitSmiComparisonOp(compiler, *locs(), kind(), branch); |
| 672 return; | 671 return; |
| 673 } | 672 } |
| 674 if (receiver_class_id() == kDoubleCid) { | 673 if (receiver_class_id() == kDoubleCid) { |
| 675 // Deoptimizes if both arguments are Smi, or if none is Double or Smi. | 674 // Deoptimizes if both arguments are Smi, or if none is Double or Smi. |
| 676 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch); | 675 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch); |
| 677 return; | 676 return; |
| 678 } | 677 } |
| 679 const bool is_checked_strict_equal = | 678 const bool is_checked_strict_equal = |
| 680 HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid); | 679 HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid); |
| 681 if (is_checked_strict_equal) { | 680 if (is_checked_strict_equal) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 // Pick arbitrary fixed input registers because this is a call. | 728 // Pick arbitrary fixed input registers because this is a call. |
| 730 locs->set_in(0, Location::RegisterLocation(RAX)); | 729 locs->set_in(0, Location::RegisterLocation(RAX)); |
| 731 locs->set_in(1, Location::RegisterLocation(RCX)); | 730 locs->set_in(1, Location::RegisterLocation(RCX)); |
| 732 locs->set_out(Location::RegisterLocation(RAX)); | 731 locs->set_out(Location::RegisterLocation(RAX)); |
| 733 return locs; | 732 return locs; |
| 734 } | 733 } |
| 735 | 734 |
| 736 | 735 |
| 737 void RelationalOpComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 736 void RelationalOpComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 738 if (operands_class_id() == kSmiCid) { | 737 if (operands_class_id() == kSmiCid) { |
| 739 EmitSmiComparisonOp(compiler, *locs(), kind(), NULL, deopt_id()); | 738 EmitSmiComparisonOp(compiler, *locs(), kind(), NULL); |
| 740 return; | 739 return; |
| 741 } | 740 } |
| 742 if (operands_class_id() == kDoubleCid) { | 741 if (operands_class_id() == kDoubleCid) { |
| 743 EmitDoubleComparisonOp(compiler, *locs(), kind(), NULL); | 742 EmitDoubleComparisonOp(compiler, *locs(), kind(), NULL); |
| 744 return; | 743 return; |
| 745 } | 744 } |
| 746 | 745 |
| 747 // Push arguments for the call. | 746 // Push arguments for the call. |
| 748 // TODO(fschneider): Split this instruction into different types to avoid | 747 // TODO(fschneider): Split this instruction into different types to avoid |
| 749 // explicitly pushing arguments to the call here. | 748 // explicitly pushing arguments to the call here. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 kNumArguments, | 786 kNumArguments, |
| 788 Array::ZoneHandle(), // No optional arguments. | 787 Array::ZoneHandle(), // No optional arguments. |
| 789 kNumArgsChecked, | 788 kNumArgsChecked, |
| 790 locs()); | 789 locs()); |
| 791 } | 790 } |
| 792 | 791 |
| 793 | 792 |
| 794 void RelationalOpComp::EmitBranchCode(FlowGraphCompiler* compiler, | 793 void RelationalOpComp::EmitBranchCode(FlowGraphCompiler* compiler, |
| 795 BranchInstr* branch) { | 794 BranchInstr* branch) { |
| 796 if (operands_class_id() == kSmiCid) { | 795 if (operands_class_id() == kSmiCid) { |
| 797 EmitSmiComparisonOp(compiler, *locs(), kind(), branch, deopt_id()); | 796 EmitSmiComparisonOp(compiler, *locs(), kind(), branch); |
| 798 return; | 797 return; |
| 799 } | 798 } |
| 800 if (operands_class_id() == kDoubleCid) { | 799 if (operands_class_id() == kDoubleCid) { |
| 801 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch); | 800 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch); |
| 802 return; | 801 return; |
| 803 } | 802 } |
| 804 EmitNativeCode(compiler); | 803 EmitNativeCode(compiler); |
| 805 __ CompareObject(RAX, compiler->bool_true()); | 804 __ CompareObject(RAX, compiler->bool_true()); |
| 806 branch->EmitBranchOnCondition(compiler, EQUAL); | 805 branch->EmitBranchOnCondition(compiler, EQUAL); |
| 807 } | 806 } |
| (...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2234 } | 2233 } |
| 2235 __ j(ABOVE_EQUAL, deopt); | 2234 __ j(ABOVE_EQUAL, deopt); |
| 2236 } | 2235 } |
| 2237 | 2236 |
| 2238 | 2237 |
| 2239 } // namespace dart | 2238 } // namespace dart |
| 2240 | 2239 |
| 2241 #undef __ | 2240 #undef __ |
| 2242 | 2241 |
| 2243 #endif // defined TARGET_ARCH_X64 | 2242 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |