| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 4367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4378 } | 4378 } |
| 4379 ASSERT((Smi::Cast(length_loc.constant()).Value() <= | 4379 ASSERT((Smi::Cast(length_loc.constant()).Value() <= |
| 4380 Smi::Cast(index_loc.constant()).Value()) || | 4380 Smi::Cast(index_loc.constant()).Value()) || |
| 4381 (Smi::Cast(index_loc.constant()).Value() < 0)); | 4381 (Smi::Cast(index_loc.constant()).Value() < 0)); |
| 4382 // Unconditionally deoptimize for constant bounds checks because they | 4382 // Unconditionally deoptimize for constant bounds checks because they |
| 4383 // only occur only when index is out-of-bounds. | 4383 // only occur only when index is out-of-bounds. |
| 4384 __ jmp(deopt); | 4384 __ jmp(deopt); |
| 4385 return; | 4385 return; |
| 4386 } | 4386 } |
| 4387 | 4387 |
| 4388 intptr_t guarded_array_length = -1; |
| 4389 if (array_ != NULL) { |
| 4390 if (array_->guarded_list_length() >= 0) { |
| 4391 guarded_array_length = array_->guarded_list_length(); |
| 4392 } |
| 4393 } |
| 4394 |
| 4395 if (index_loc.IsConstant() && guarded_array_length >= 0) { |
| 4396 const Object& index = Smi::Cast(index_loc.constant()); |
| 4397 int32_t i = reinterpret_cast<int32_t>(index.raw()); |
| 4398 if (i >= guarded_array_length) { |
| 4399 // We know this bounds check will trigger a deoptimization. |
| 4400 __ jmp(deopt); |
| 4401 } |
| 4402 // Nothing to emit. |
| 4403 return; |
| 4404 } |
| 4405 |
| 4388 if (index_loc.IsConstant()) { | 4406 if (index_loc.IsConstant()) { |
| 4389 Register length = length_loc.reg(); | 4407 Register length = length_loc.reg(); |
| 4390 const Object& index = Smi::Cast(index_loc.constant()); | 4408 const Object& index = Smi::Cast(index_loc.constant()); |
| 4391 __ cmpl(length, Immediate(reinterpret_cast<int32_t>(index.raw()))); | 4409 __ cmpl(length, Immediate(reinterpret_cast<int32_t>(index.raw()))); |
| 4392 __ j(BELOW_EQUAL, deopt); | 4410 __ j(BELOW_EQUAL, deopt); |
| 4393 } else if (length_loc.IsConstant()) { | 4411 } else if (length_loc.IsConstant()) { |
| 4394 const Smi& length = Smi::Cast(length_loc.constant()); | 4412 const Smi& length = Smi::Cast(length_loc.constant()); |
| 4395 Register index = index_loc.reg(); | 4413 Register index = index_loc.reg(); |
| 4396 __ cmpl(index, Immediate(reinterpret_cast<int32_t>(length.raw()))); | 4414 __ cmpl(index, Immediate(reinterpret_cast<int32_t>(length.raw()))); |
| 4397 __ j(ABOVE_EQUAL, deopt); | 4415 __ j(ABOVE_EQUAL, deopt); |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5179 PcDescriptors::kOther, | 5197 PcDescriptors::kOther, |
| 5180 locs()); | 5198 locs()); |
| 5181 __ Drop(2); // Discard type arguments and receiver. | 5199 __ Drop(2); // Discard type arguments and receiver. |
| 5182 } | 5200 } |
| 5183 | 5201 |
| 5184 } // namespace dart | 5202 } // namespace dart |
| 5185 | 5203 |
| 5186 #undef __ | 5204 #undef __ |
| 5187 | 5205 |
| 5188 #endif // defined TARGET_ARCH_IA32 | 5206 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |