| 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 4419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4430 } | 4430 } |
| 4431 ASSERT((Smi::Cast(length_loc.constant()).Value() <= | 4431 ASSERT((Smi::Cast(length_loc.constant()).Value() <= |
| 4432 Smi::Cast(index_loc.constant()).Value()) || | 4432 Smi::Cast(index_loc.constant()).Value()) || |
| 4433 (Smi::Cast(index_loc.constant()).Value() < 0)); | 4433 (Smi::Cast(index_loc.constant()).Value() < 0)); |
| 4434 // Unconditionally deoptimize for constant bounds checks because they | 4434 // Unconditionally deoptimize for constant bounds checks because they |
| 4435 // only occur only when index is out-of-bounds. | 4435 // only occur only when index is out-of-bounds. |
| 4436 __ jmp(deopt); | 4436 __ jmp(deopt); |
| 4437 return; | 4437 return; |
| 4438 } | 4438 } |
| 4439 | 4439 |
| 4440 intptr_t guarded_array_length = -1; |
| 4441 if (array_ != NULL) { |
| 4442 if (array_->guarded_list_length() >= 0) { |
| 4443 guarded_array_length = array_->guarded_list_length(); |
| 4444 } |
| 4445 } |
| 4446 |
| 4447 if (index_loc.IsConstant() && guarded_array_length >= 0) { |
| 4448 const Object& index = Smi::Cast(index_loc.constant()); |
| 4449 int64_t i = reinterpret_cast<int64_t>(index.raw()); |
| 4450 if (i >= guarded_array_length) { |
| 4451 // We know this bounds check will trigger a deoptimization. |
| 4452 __ jmp(deopt); |
| 4453 } |
| 4454 // Nothing to emit. |
| 4455 return; |
| 4456 } |
| 4457 |
| 4440 if (index_loc.IsConstant()) { | 4458 if (index_loc.IsConstant()) { |
| 4441 Register length = length_loc.reg(); | 4459 Register length = length_loc.reg(); |
| 4442 const Smi& index = Smi::Cast(index_loc.constant()); | 4460 const Smi& index = Smi::Cast(index_loc.constant()); |
| 4443 __ cmpq(length, Immediate(reinterpret_cast<int64_t>(index.raw()))); | 4461 __ cmpq(length, Immediate(reinterpret_cast<int64_t>(index.raw()))); |
| 4444 __ j(BELOW_EQUAL, deopt); | 4462 __ j(BELOW_EQUAL, deopt); |
| 4445 } else if (length_loc.IsConstant()) { | 4463 } else if (length_loc.IsConstant()) { |
| 4446 const Smi& length = Smi::Cast(length_loc.constant()); | 4464 const Smi& length = Smi::Cast(length_loc.constant()); |
| 4447 Register index = index_loc.reg(); | 4465 Register index = index_loc.reg(); |
| 4448 __ cmpq(index, Immediate(reinterpret_cast<int64_t>(length.raw()))); | 4466 __ cmpq(index, Immediate(reinterpret_cast<int64_t>(length.raw()))); |
| 4449 __ j(ABOVE_EQUAL, deopt); | 4467 __ j(ABOVE_EQUAL, deopt); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4795 PcDescriptors::kOther, | 4813 PcDescriptors::kOther, |
| 4796 locs()); | 4814 locs()); |
| 4797 __ Drop(2); // Discard type arguments and receiver. | 4815 __ Drop(2); // Discard type arguments and receiver. |
| 4798 } | 4816 } |
| 4799 | 4817 |
| 4800 } // namespace dart | 4818 } // namespace dart |
| 4801 | 4819 |
| 4802 #undef __ | 4820 #undef __ |
| 4803 | 4821 |
| 4804 #endif // defined TARGET_ARCH_X64 | 4822 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |