| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 | 649 |
| 650 | 650 |
| 651 void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 651 void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
| 652 BranchInstr* branch) { | 652 BranchInstr* branch) { |
| 653 BranchLabels labels = compiler->CreateBranchLabels(branch); | 653 BranchLabels labels = compiler->CreateBranchLabels(branch); |
| 654 Condition true_condition = EmitComparisonCode(compiler, labels); | 654 Condition true_condition = EmitComparisonCode(compiler, labels); |
| 655 EmitBranchOnCondition(compiler, true_condition, labels); | 655 EmitBranchOnCondition(compiler, true_condition, labels); |
| 656 } | 656 } |
| 657 | 657 |
| 658 | 658 |
| 659 LocationSummary* TestCidsInstr::MakeLocationSummary(bool opt) const { |
| 660 const intptr_t kNumInputs = 1; |
| 661 const intptr_t kNumTemps = 1; |
| 662 LocationSummary* locs = |
| 663 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 664 locs->set_in(0, Location::RequiresRegister()); |
| 665 locs->set_temp(0, Location::RequiresRegister()); |
| 666 locs->set_out(0, Location::RequiresRegister()); |
| 667 return locs; |
| 668 } |
| 669 |
| 670 |
| 671 Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler, |
| 672 BranchLabels labels) { |
| 673 ASSERT((kind() == Token::kIS) || (kind() == Token::kISNOT)); |
| 674 Register val_reg = locs()->in(0).reg(); |
| 675 Register cid_reg = locs()->temp(0).reg(); |
| 676 |
| 677 Label* deopt = CanDeoptimize() ? |
| 678 compiler->AddDeoptStub(deopt_id(), kDeoptTestCids) : NULL; |
| 679 |
| 680 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0; |
| 681 const ZoneGrowableArray<intptr_t>& data = cid_results(); |
| 682 ASSERT(data[0] == kSmiCid); |
| 683 bool result = data[1] == true_result; |
| 684 __ andi(CMPRES1, val_reg, Immediate(kSmiTagMask)); |
| 685 __ beq(CMPRES1, ZR, result ? labels.true_label : labels.false_label); |
| 686 |
| 687 __ LoadClassId(cid_reg, val_reg); |
| 688 for (intptr_t i = 2; i < data.length(); i += 2) { |
| 689 const intptr_t test_cid = data[i]; |
| 690 ASSERT(test_cid != kSmiCid); |
| 691 result = data[i + 1] == true_result; |
| 692 __ BranchEqual(cid_reg, test_cid, |
| 693 result ? labels.true_label : labels.false_label); |
| 694 } |
| 695 // No match found, deoptimize or false. |
| 696 if (deopt == NULL) { |
| 697 Label* target = result ? labels.false_label : labels.true_label; |
| 698 if (target != labels.fall_through) { |
| 699 __ b(target); |
| 700 } |
| 701 } else { |
| 702 __ b(deopt); |
| 703 } |
| 704 // Dummy result as the last instruction is a jump, any conditional |
| 705 // branch using the result will therefore be skipped. |
| 706 return EQ; |
| 707 } |
| 708 |
| 709 |
| 710 void TestCidsInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
| 711 BranchInstr* branch) { |
| 712 BranchLabels labels = compiler->CreateBranchLabels(branch); |
| 713 EmitComparisonCode(compiler, labels); |
| 714 } |
| 715 |
| 716 |
| 717 void TestCidsInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 718 Register result_reg = locs()->out(0).reg(); |
| 719 Label is_true, is_false, done; |
| 720 BranchLabels labels = { &is_true, &is_false, &is_false }; |
| 721 EmitComparisonCode(compiler, labels); |
| 722 __ Bind(&is_false); |
| 723 __ LoadObject(result_reg, Bool::False()); |
| 724 __ b(&done); |
| 725 __ Bind(&is_true); |
| 726 __ LoadObject(result_reg, Bool::True()); |
| 727 __ Bind(&done); |
| 728 } |
| 729 |
| 730 |
| 659 LocationSummary* RelationalOpInstr::MakeLocationSummary(bool opt) const { | 731 LocationSummary* RelationalOpInstr::MakeLocationSummary(bool opt) const { |
| 660 const intptr_t kNumInputs = 2; | 732 const intptr_t kNumInputs = 2; |
| 661 const intptr_t kNumTemps = 0; | 733 const intptr_t kNumTemps = 0; |
| 662 if (operation_cid() == kMintCid) { | 734 if (operation_cid() == kMintCid) { |
| 663 const intptr_t kNumTemps = 2; | 735 const intptr_t kNumTemps = 2; |
| 664 LocationSummary* locs = | 736 LocationSummary* locs = |
| 665 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 737 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 666 locs->set_in(0, Location::RequiresFpuRegister()); | 738 locs->set_in(0, Location::RequiresFpuRegister()); |
| 667 locs->set_in(1, Location::RequiresFpuRegister()); | 739 locs->set_in(1, Location::RequiresFpuRegister()); |
| 668 locs->set_temp(0, Location::RequiresRegister()); | 740 locs->set_temp(0, Location::RequiresRegister()); |
| (...skipping 3720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4389 compiler->GenerateCall(token_pos(), | 4461 compiler->GenerateCall(token_pos(), |
| 4390 &label, | 4462 &label, |
| 4391 PcDescriptors::kOther, | 4463 PcDescriptors::kOther, |
| 4392 locs()); | 4464 locs()); |
| 4393 __ Drop(ArgumentCount()); // Discard arguments. | 4465 __ Drop(ArgumentCount()); // Discard arguments. |
| 4394 } | 4466 } |
| 4395 | 4467 |
| 4396 } // namespace dart | 4468 } // namespace dart |
| 4397 | 4469 |
| 4398 #endif // defined TARGET_ARCH_MIPS | 4470 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |