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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 (Utils::IsPowerOfTwo(v2) && (v1 == 0)); | 129 (Utils::IsPowerOfTwo(v2) && (v1 == 0)); |
130 } | 130 } |
131 | 131 |
132 | 132 |
133 LocationSummary* IfThenElseInstr::MakeLocationSummary() const { | 133 LocationSummary* IfThenElseInstr::MakeLocationSummary() const { |
134 const intptr_t kNumInputs = 2; | 134 const intptr_t kNumInputs = 2; |
135 const intptr_t kNumTemps = 0; | 135 const intptr_t kNumTemps = 0; |
136 LocationSummary* locs = | 136 LocationSummary* locs = |
137 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 137 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
138 locs->set_in(0, Location::RegisterOrConstant(left())); | 138 locs->set_in(0, Location::RegisterOrConstant(left())); |
139 locs->set_in(1, Location::RegisterOrConstant(right())); | 139 // Only one of the inputs can be a constant. Choose register if the first one |
| 140 // is a constant. |
| 141 locs->set_in(1, locs->in(0).IsConstant() |
| 142 ? Location::RequiresRegister() |
| 143 : Location::RegisterOrConstant(right())); |
140 // TODO(vegorov): support byte register constraints in the register allocator. | 144 // TODO(vegorov): support byte register constraints in the register allocator. |
141 locs->set_out(Location::RegisterLocation(RDX)); | 145 locs->set_out(Location::RegisterLocation(RDX)); |
142 return locs; | 146 return locs; |
143 } | 147 } |
144 | 148 |
145 | 149 |
146 void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 150 void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
147 ASSERT(locs()->out().reg() == RDX); | 151 ASSERT(locs()->out().reg() == RDX); |
148 ASSERT(Token::IsEqualityOperator(kind())); | 152 ASSERT(Token::IsEqualityOperator(kind())); |
149 | 153 |
150 Location left = locs()->in(0); | 154 Location left = locs()->in(0); |
151 Location right = locs()->in(1); | 155 Location right = locs()->in(1); |
152 if (left.IsConstant() && right.IsConstant()) { | |
153 // TODO(srdjan): Determine why this instruction was not eliminated. | |
154 bool result = (left.constant().raw() == right.constant().raw()); | |
155 if ((kind_ == Token::kNE_STRICT) || (kind_ == Token::kNE)) { | |
156 result = !result; | |
157 } | |
158 __ LoadImmediate(locs()->out().reg(), | |
159 Immediate(reinterpret_cast<int64_t>( | |
160 Smi::New(result ? if_true_ : if_false_))), PP); | |
161 return; | |
162 } | |
163 | |
164 ASSERT(!left.IsConstant() || !right.IsConstant()); | 156 ASSERT(!left.IsConstant() || !right.IsConstant()); |
165 | 157 |
166 // Clear upper part of the out register. We are going to use setcc on it | 158 // Clear upper part of the out register. We are going to use setcc on it |
167 // which is a byte move. | 159 // which is a byte move. |
168 __ xorq(RDX, RDX); | 160 __ xorq(RDX, RDX); |
169 | 161 |
170 // Compare left and right. For now only equality comparison is supported. | 162 // Compare left and right. For now only equality comparison is supported. |
171 // TODO(vegorov): reuse code from the other comparison instructions instead of | 163 // TODO(vegorov): reuse code from the other comparison instructions instead of |
172 // generating it inline here. | 164 // generating it inline here. |
173 if (left.IsConstant()) { | 165 if (left.IsConstant()) { |
(...skipping 4406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4580 PcDescriptors::kOther, | 4572 PcDescriptors::kOther, |
4581 locs()); | 4573 locs()); |
4582 __ Drop(2); // Discard type arguments and receiver. | 4574 __ Drop(2); // Discard type arguments and receiver. |
4583 } | 4575 } |
4584 | 4576 |
4585 } // namespace dart | 4577 } // namespace dart |
4586 | 4578 |
4587 #undef __ | 4579 #undef __ |
4588 | 4580 |
4589 #endif // defined TARGET_ARCH_X64 | 4581 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |