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

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

Issue 62203018: Remove dead code from IfThenElse and StrictCompare in the compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « runtime/vm/intermediate_language.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) 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 (Utils::IsPowerOfTwo(v2) && (v1 == 0)); 134 (Utils::IsPowerOfTwo(v2) && (v1 == 0));
135 } 135 }
136 136
137 137
138 LocationSummary* IfThenElseInstr::MakeLocationSummary() const { 138 LocationSummary* IfThenElseInstr::MakeLocationSummary() const {
139 const intptr_t kNumInputs = 2; 139 const intptr_t kNumInputs = 2;
140 const intptr_t kNumTemps = 0; 140 const intptr_t kNumTemps = 0;
141 LocationSummary* locs = 141 LocationSummary* locs =
142 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 142 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
143 locs->set_in(0, Location::RegisterOrConstant(left())); 143 locs->set_in(0, Location::RegisterOrConstant(left()));
144 locs->set_in(1, Location::RegisterOrConstant(right())); 144 // Only one of the inputs can be a constant. Choose register if the first one
145 // is a constant.
146 locs->set_in(1, locs->in(0).IsConstant()
147 ? Location::RequiresRegister()
148 : Location::RegisterOrConstant(right()));
145 locs->set_out(Location::RequiresRegister()); 149 locs->set_out(Location::RequiresRegister());
146 return locs; 150 return locs;
147 } 151 }
148 152
149 153
150 void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 154 void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
151 const Register result = locs()->out().reg(); 155 const Register result = locs()->out().reg();
152 ASSERT(Token::IsEqualityOperator(kind())); 156 ASSERT(Token::IsEqualityOperator(kind()));
153 157
154 Location left = locs()->in(0); 158 Location left = locs()->in(0);
155 Location right = locs()->in(1); 159 Location right = locs()->in(1);
156 if (left.IsConstant() && right.IsConstant()) {
157 // TODO(srdjan): Determine why this instruction was not eliminated.
158 bool res = (left.constant().raw() == right.constant().raw());
159 if ((kind_ == Token::kNE_STRICT) || (kind_ == Token::kNE)) {
160 res = !res;
161 }
162 __ LoadImmediate(locs()->out().reg(),
163 reinterpret_cast<int32_t>(Smi::New(res ? if_true_ : if_false_)));
164 return;
165 }
166
167 ASSERT(!left.IsConstant() || !right.IsConstant()); 160 ASSERT(!left.IsConstant() || !right.IsConstant());
168 161
169 // Clear out register. 162 // Clear out register.
170 __ eor(result, result, ShifterOperand(result)); 163 __ eor(result, result, ShifterOperand(result));
171 164
172 // Compare left and right. For now only equality comparison is supported. 165 // Compare left and right. For now only equality comparison is supported.
173 // TODO(vegorov): reuse code from the other comparison instructions instead of 166 // TODO(vegorov): reuse code from the other comparison instructions instead of
174 // generating it inline here. 167 // generating it inline here.
175 if (left.IsConstant()) { 168 if (left.IsConstant()) {
176 __ CompareObject(right.reg(), left.constant()); 169 __ CompareObject(right.reg(), left.constant());
(...skipping 4376 matching lines...) Expand 10 before | Expand all | Expand 10 after
4553 compiler->GenerateCall(token_pos(), 4546 compiler->GenerateCall(token_pos(),
4554 &label, 4547 &label,
4555 PcDescriptors::kOther, 4548 PcDescriptors::kOther,
4556 locs()); 4549 locs());
4557 __ Drop(2); // Discard type arguments and receiver. 4550 __ Drop(2); // Discard type arguments and receiver.
4558 } 4551 }
4559 4552
4560 } // namespace dart 4553 } // namespace dart
4561 4554
4562 #endif // defined TARGET_ARCH_ARM 4555 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698