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

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

Issue 258563004: Copy of Issue 231383002 after hard disk crash: First step in improving instance of test for a fixed… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
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_ARM. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 const int32_t imm = 669 const int32_t imm =
670 reinterpret_cast<int32_t>(right.constant().raw()); 670 reinterpret_cast<int32_t>(right.constant().raw());
671 __ TestImmediate(left, imm); 671 __ TestImmediate(left, imm);
672 } else { 672 } else {
673 __ tst(left, ShifterOperand(right.reg())); 673 __ tst(left, ShifterOperand(right.reg()));
674 } 674 }
675 Condition true_condition = (kind() == Token::kNE) ? NE : EQ; 675 Condition true_condition = (kind() == Token::kNE) ? NE : EQ;
676 return true_condition; 676 return true_condition;
677 } 677 }
678 678
679
679 void TestSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 680 void TestSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
680 // Never emitted outside of the BranchInstr. 681 // Never emitted outside of the BranchInstr.
681 UNREACHABLE(); 682 UNREACHABLE();
682 } 683 }
683 684
684 685
685 void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler, 686 void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler,
686 BranchInstr* branch) { 687 BranchInstr* branch) {
687 BranchLabels labels = compiler->CreateBranchLabels(branch); 688 BranchLabels labels = compiler->CreateBranchLabels(branch);
688 Condition true_condition = EmitComparisonCode(compiler, labels); 689 Condition true_condition = EmitComparisonCode(compiler, labels);
689 EmitBranchOnCondition(compiler, true_condition, labels); 690 EmitBranchOnCondition(compiler, true_condition, labels);
690 } 691 }
691 692
692 693
694 LocationSummary* TestCidsInstr::MakeLocationSummary(bool opt) const {
695 const intptr_t kNumInputs = 1;
696 const intptr_t kNumTemps = 1;
697 LocationSummary* locs =
698 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
699 locs->set_in(0, Location::RequiresRegister());
700 locs->set_temp(0, Location::RequiresRegister());
701 locs->set_out(0, Location::RequiresRegister());
702 return locs;
703 }
704
705
706 Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
707 BranchLabels labels) {
708 ASSERT((kind() == Token::kIS) || (kind() == Token::kISNOT));
709 Register val_reg = locs()->in(0).reg();
710 Register cid_reg = locs()->temp(0).reg();
711
712 Label* deopt = CanDeoptimize() ?
713 compiler->AddDeoptStub(deopt_id(), kDeoptTestCids) : NULL;
714
715 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0;
716 const ZoneGrowableArray<intptr_t>& data = cid_results();
717 ASSERT(data[0] == kSmiCid);
718 bool result = data[1] == true_result;
719 __ tst(val_reg, ShifterOperand(kSmiTagMask));
720 __ b(result ? labels.true_label : labels.false_label, EQ);
721 __ LoadClassId(cid_reg, val_reg);
722
723 for (intptr_t i = 2; i < data.length(); i += 2) {
724 const intptr_t test_cid = data[i];
725 ASSERT(test_cid != kSmiCid);
726 result = data[i + 1] == true_result;
727 __ CompareImmediate(cid_reg, test_cid);
728 __ b(result ? labels.true_label : labels.false_label, EQ);
729 }
730 // No match found, deoptimize or false.
731 if (deopt == NULL) {
732 Label* target = result ? labels.false_label : labels.true_label;
733 if (target != labels.fall_through) {
734 __ b(target);
735 }
736 } else {
737 __ b(deopt);
738 }
739 // Dummy result as the last instruction is a jump, any conditional
740 // branch using the result will therefore be skipped.
741 return EQ;
742 }
743
744
745 void TestCidsInstr::EmitBranchCode(FlowGraphCompiler* compiler,
746 BranchInstr* branch) {
747 BranchLabels labels = compiler->CreateBranchLabels(branch);
748 EmitComparisonCode(compiler, labels);
749 }
750
751
752 void TestCidsInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
753 Register result_reg = locs()->out(0).reg();
754 Label is_true, is_false, done;
755 BranchLabels labels = { &is_true, &is_false, &is_false };
756 EmitComparisonCode(compiler, labels);
757 __ Bind(&is_false);
758 __ LoadObject(result_reg, Bool::False());
759 __ b(&done);
760 __ Bind(&is_true);
761 __ LoadObject(result_reg, Bool::True());
762 __ Bind(&done);
763 }
764
765
693 LocationSummary* RelationalOpInstr::MakeLocationSummary(bool opt) const { 766 LocationSummary* RelationalOpInstr::MakeLocationSummary(bool opt) const {
694 const intptr_t kNumInputs = 2; 767 const intptr_t kNumInputs = 2;
695 const intptr_t kNumTemps = 0; 768 const intptr_t kNumTemps = 0;
696 if (operation_cid() == kMintCid) { 769 if (operation_cid() == kMintCid) {
697 const intptr_t kNumTemps = 2; 770 const intptr_t kNumTemps = 2;
698 LocationSummary* locs = 771 LocationSummary* locs =
699 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 772 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
700 locs->set_in(0, Location::RequiresFpuRegister()); 773 locs->set_in(0, Location::RequiresFpuRegister());
701 locs->set_in(1, Location::RequiresFpuRegister()); 774 locs->set_in(1, Location::RequiresFpuRegister());
702 locs->set_temp(0, Location::RequiresRegister()); 775 locs->set_temp(0, Location::RequiresRegister());
(...skipping 5241 matching lines...) Expand 10 before | Expand all | Expand 10 after
5944 compiler->GenerateCall(token_pos(), 6017 compiler->GenerateCall(token_pos(),
5945 &label, 6018 &label,
5946 PcDescriptors::kOther, 6019 PcDescriptors::kOther,
5947 locs()); 6020 locs());
5948 __ Drop(ArgumentCount()); // Discard arguments. 6021 __ Drop(ArgumentCount()); // Discard arguments.
5949 } 6022 }
5950 6023
5951 } // namespace dart 6024 } // namespace dart
5952 6025
5953 #endif // defined TARGET_ARCH_ARM 6026 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698