| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 (Utils::IsPowerOfTwo(v2) && (v1 == 0)); | 133 (Utils::IsPowerOfTwo(v2) && (v1 == 0)); |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 LocationSummary* IfThenElseInstr::MakeLocationSummary() const { | 137 LocationSummary* IfThenElseInstr::MakeLocationSummary() const { |
| 138 const intptr_t kNumInputs = 2; | 138 const intptr_t kNumInputs = 2; |
| 139 const intptr_t kNumTemps = 0; | 139 const intptr_t kNumTemps = 0; |
| 140 LocationSummary* locs = | 140 LocationSummary* locs = |
| 141 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 141 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 142 locs->set_in(0, Location::RegisterOrConstant(left())); | 142 locs->set_in(0, Location::RegisterOrConstant(left())); |
| 143 locs->set_in(1, Location::RegisterOrConstant(right())); | 143 // Only one of the inputs can be a constant. Choose register if the first one |
| 144 // is a constant. |
| 145 locs->set_in(1, locs->in(0).IsConstant() |
| 146 ? Location::RequiresRegister() |
| 147 : Location::RegisterOrConstant(right())); |
| 144 locs->set_out(Location::RequiresRegister()); | 148 locs->set_out(Location::RequiresRegister()); |
| 145 return locs; | 149 return locs; |
| 146 } | 150 } |
| 147 | 151 |
| 148 | 152 |
| 149 void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 153 void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 150 const Register result = locs()->out().reg(); | 154 const Register result = locs()->out().reg(); |
| 151 ASSERT(Token::IsEqualityOperator(kind())); | 155 ASSERT(Token::IsEqualityOperator(kind())); |
| 152 | 156 |
| 153 Location left = locs()->in(0); | 157 Location left = locs()->in(0); |
| 154 Location right = locs()->in(1); | 158 Location right = locs()->in(1); |
| 155 if (left.IsConstant() && right.IsConstant()) { | |
| 156 // TODO(srdjan): Determine why this instruction was not eliminated. | |
| 157 bool res = (left.constant().raw() == right.constant().raw()); | |
| 158 if ((kind_ == Token::kNE_STRICT) || (kind_ == Token::kNE)) { | |
| 159 res = !res; | |
| 160 } | |
| 161 __ LoadImmediate(result, | |
| 162 reinterpret_cast<int32_t>(Smi::New(res ? if_true_ : if_false_))); | |
| 163 return; | |
| 164 } | |
| 165 | |
| 166 ASSERT(!left.IsConstant() || !right.IsConstant()); | 159 ASSERT(!left.IsConstant() || !right.IsConstant()); |
| 167 | 160 |
| 168 // Clear out register. | 161 // Clear out register. |
| 169 __ mov(result, ZR); | 162 __ mov(result, ZR); |
| 170 | 163 |
| 171 // Compare left and right. For now only equality comparison is supported. | 164 // Compare left and right. For now only equality comparison is supported. |
| 172 // TODO(vegorov): reuse code from the other comparison instructions instead of | 165 // TODO(vegorov): reuse code from the other comparison instructions instead of |
| 173 // generating it inline here. | 166 // generating it inline here. |
| 174 if (left.IsConstant()) { | 167 if (left.IsConstant()) { |
| 175 __ CompareObject(CMPRES1, CMPRES2, right.reg(), left.constant()); | 168 __ CompareObject(CMPRES1, CMPRES2, right.reg(), left.constant()); |
| (...skipping 3726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3902 compiler->GenerateCall(token_pos(), | 3895 compiler->GenerateCall(token_pos(), |
| 3903 &label, | 3896 &label, |
| 3904 PcDescriptors::kOther, | 3897 PcDescriptors::kOther, |
| 3905 locs()); | 3898 locs()); |
| 3906 __ Drop(2); // Discard type arguments and receiver. | 3899 __ Drop(2); // Discard type arguments and receiver. |
| 3907 } | 3900 } |
| 3908 | 3901 |
| 3909 } // namespace dart | 3902 } // namespace dart |
| 3910 | 3903 |
| 3911 #endif // defined TARGET_ARCH_MIPS | 3904 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |