| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 __ pushl(right); | 552 __ pushl(right); |
| 553 EmitEqualityAsPolymorphicCall(compiler, ic_data, locs, branch, kind, | 553 EmitEqualityAsPolymorphicCall(compiler, ic_data, locs, branch, kind, |
| 554 deopt_id, token_pos); | 554 deopt_id, token_pos); |
| 555 __ Bind(&done); | 555 __ Bind(&done); |
| 556 } | 556 } |
| 557 | 557 |
| 558 | 558 |
| 559 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, | 559 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, |
| 560 const LocationSummary& locs, | 560 const LocationSummary& locs, |
| 561 Token::Kind kind, | 561 Token::Kind kind, |
| 562 BranchInstr* branch, | 562 BranchInstr* branch) { |
| 563 intptr_t deopt_id) { | |
| 564 Register left = locs.in(0).reg(); | 563 Register left = locs.in(0).reg(); |
| 565 Register right = locs.in(1).reg(); | 564 Register right = locs.in(1).reg(); |
| 566 | 565 |
| 567 Condition true_condition = TokenKindToSmiCondition(kind); | 566 Condition true_condition = TokenKindToSmiCondition(kind); |
| 568 __ cmpl(left, right); | 567 __ cmpl(left, right); |
| 569 | 568 |
| 570 if (branch != NULL) { | 569 if (branch != NULL) { |
| 571 branch->EmitBranchOnCondition(compiler, true_condition); | 570 branch->EmitBranchOnCondition(compiler, true_condition); |
| 572 } else { | 571 } else { |
| 573 Register result = locs.out().reg(); | 572 Register result = locs.out().reg(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 true_condition, left, right, locs.out().reg()); | 612 true_condition, left, right, locs.out().reg()); |
| 614 } | 613 } |
| 615 } | 614 } |
| 616 | 615 |
| 617 | 616 |
| 618 void EqualityCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 617 void EqualityCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 619 ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ)); | 618 ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ)); |
| 620 BranchInstr* kNoBranch = NULL; | 619 BranchInstr* kNoBranch = NULL; |
| 621 if (receiver_class_id() == kSmiCid) { | 620 if (receiver_class_id() == kSmiCid) { |
| 622 // Deoptimizes if both arguments not Smi. | 621 // Deoptimizes if both arguments not Smi. |
| 623 EmitSmiComparisonOp(compiler, *locs(), kind(), kNoBranch, deopt_id()); | 622 EmitSmiComparisonOp(compiler, *locs(), kind(), kNoBranch); |
| 624 return; | 623 return; |
| 625 } | 624 } |
| 626 if (receiver_class_id() == kDoubleCid) { | 625 if (receiver_class_id() == kDoubleCid) { |
| 627 EmitDoubleComparisonOp(compiler, *locs(), kind(), kNoBranch); | 626 EmitDoubleComparisonOp(compiler, *locs(), kind(), kNoBranch); |
| 628 return; | 627 return; |
| 629 } | 628 } |
| 630 const bool is_checked_strict_equal = | 629 const bool is_checked_strict_equal = |
| 631 HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid); | 630 HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid); |
| 632 if (is_checked_strict_equal) { | 631 if (is_checked_strict_equal) { |
| 633 EmitCheckedStrictEqual(compiler, *ic_data(), *locs(), kind(), kNoBranch, | 632 EmitCheckedStrictEqual(compiler, *ic_data(), *locs(), kind(), kNoBranch, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 646 EmitEqualityAsInstanceCall(compiler, deopt_id(), token_pos(), kind(), locs()); | 645 EmitEqualityAsInstanceCall(compiler, deopt_id(), token_pos(), kind(), locs()); |
| 647 ASSERT(locs()->out().reg() == EAX); | 646 ASSERT(locs()->out().reg() == EAX); |
| 648 } | 647 } |
| 649 | 648 |
| 650 | 649 |
| 651 void EqualityCompareComp::EmitBranchCode(FlowGraphCompiler* compiler, | 650 void EqualityCompareComp::EmitBranchCode(FlowGraphCompiler* compiler, |
| 652 BranchInstr* branch) { | 651 BranchInstr* branch) { |
| 653 ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ)); | 652 ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ)); |
| 654 if (receiver_class_id() == kSmiCid) { | 653 if (receiver_class_id() == kSmiCid) { |
| 655 // Deoptimizes if both arguments not Smi. | 654 // Deoptimizes if both arguments not Smi. |
| 656 EmitSmiComparisonOp(compiler, *locs(), kind(), branch, deopt_id()); | 655 EmitSmiComparisonOp(compiler, *locs(), kind(), branch); |
| 657 return; | 656 return; |
| 658 } | 657 } |
| 659 if (receiver_class_id() == kDoubleCid) { | 658 if (receiver_class_id() == kDoubleCid) { |
| 660 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch); | 659 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch); |
| 661 return; | 660 return; |
| 662 } | 661 } |
| 663 const bool is_checked_strict_equal = | 662 const bool is_checked_strict_equal = |
| 664 HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid); | 663 HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid); |
| 665 if (is_checked_strict_equal) { | 664 if (is_checked_strict_equal) { |
| 666 EmitCheckedStrictEqual(compiler, *ic_data(), *locs(), kind(), branch, | 665 EmitCheckedStrictEqual(compiler, *ic_data(), *locs(), kind(), branch, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 // Pick arbitrary fixed input registers because this is a call. | 712 // Pick arbitrary fixed input registers because this is a call. |
| 714 locs->set_in(0, Location::RegisterLocation(EAX)); | 713 locs->set_in(0, Location::RegisterLocation(EAX)); |
| 715 locs->set_in(1, Location::RegisterLocation(ECX)); | 714 locs->set_in(1, Location::RegisterLocation(ECX)); |
| 716 locs->set_out(Location::RegisterLocation(EAX)); | 715 locs->set_out(Location::RegisterLocation(EAX)); |
| 717 return locs; | 716 return locs; |
| 718 } | 717 } |
| 719 | 718 |
| 720 | 719 |
| 721 void RelationalOpComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 720 void RelationalOpComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 722 if (operands_class_id() == kSmiCid) { | 721 if (operands_class_id() == kSmiCid) { |
| 723 EmitSmiComparisonOp(compiler, *locs(), kind(), NULL, deopt_id()); | 722 EmitSmiComparisonOp(compiler, *locs(), kind(), NULL); |
| 724 return; | 723 return; |
| 725 } | 724 } |
| 726 if (operands_class_id() == kDoubleCid) { | 725 if (operands_class_id() == kDoubleCid) { |
| 727 EmitDoubleComparisonOp(compiler, *locs(), kind(), NULL); | 726 EmitDoubleComparisonOp(compiler, *locs(), kind(), NULL); |
| 728 return; | 727 return; |
| 729 } | 728 } |
| 730 | 729 |
| 731 // Push arguments for the call. | 730 // Push arguments for the call. |
| 732 // TODO(fschneider): Split this instruction into different types to avoid | 731 // TODO(fschneider): Split this instruction into different types to avoid |
| 733 // explicitly pushing arguments to the call here. | 732 // explicitly pushing arguments to the call here. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 kNumArguments, | 769 kNumArguments, |
| 771 Array::ZoneHandle(), // No optional arguments. | 770 Array::ZoneHandle(), // No optional arguments. |
| 772 kNumArgsChecked, | 771 kNumArgsChecked, |
| 773 locs()); | 772 locs()); |
| 774 } | 773 } |
| 775 | 774 |
| 776 | 775 |
| 777 void RelationalOpComp::EmitBranchCode(FlowGraphCompiler* compiler, | 776 void RelationalOpComp::EmitBranchCode(FlowGraphCompiler* compiler, |
| 778 BranchInstr* branch) { | 777 BranchInstr* branch) { |
| 779 if (operands_class_id() == kSmiCid) { | 778 if (operands_class_id() == kSmiCid) { |
| 780 EmitSmiComparisonOp(compiler, *locs(), kind(), branch, deopt_id()); | 779 EmitSmiComparisonOp(compiler, *locs(), kind(), branch); |
| 781 return; | 780 return; |
| 782 } | 781 } |
| 783 if (operands_class_id() == kDoubleCid) { | 782 if (operands_class_id() == kDoubleCid) { |
| 784 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch); | 783 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch); |
| 785 return; | 784 return; |
| 786 } | 785 } |
| 787 EmitNativeCode(compiler); | 786 EmitNativeCode(compiler); |
| 788 __ CompareObject(EAX, compiler->bool_true()); | 787 __ CompareObject(EAX, compiler->bool_true()); |
| 789 branch->EmitBranchOnCondition(compiler, EQUAL); | 788 branch->EmitBranchOnCondition(compiler, EQUAL); |
| 790 } | 789 } |
| (...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2220 } | 2219 } |
| 2221 __ j(ABOVE_EQUAL, deopt); | 2220 __ j(ABOVE_EQUAL, deopt); |
| 2222 } | 2221 } |
| 2223 | 2222 |
| 2224 | 2223 |
| 2225 } // namespace dart | 2224 } // namespace dart |
| 2226 | 2225 |
| 2227 #undef __ | 2226 #undef __ |
| 2228 | 2227 |
| 2229 #endif // defined TARGET_ARCH_X64 | 2228 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |