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

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

Issue 23003026: Avoid array bounds check when allowed by guarded field. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months 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
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_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 3700 matching lines...) Expand 10 before | Expand all | Expand 10 after
3711 } 3711 }
3712 ASSERT((Smi::Cast(length_loc.constant()).Value() <= 3712 ASSERT((Smi::Cast(length_loc.constant()).Value() <=
3713 Smi::Cast(index_loc.constant()).Value()) || 3713 Smi::Cast(index_loc.constant()).Value()) ||
3714 (Smi::Cast(index_loc.constant()).Value() < 0)); 3714 (Smi::Cast(index_loc.constant()).Value() < 0));
3715 // Unconditionally deoptimize for constant bounds checks because they 3715 // Unconditionally deoptimize for constant bounds checks because they
3716 // only occur only when index is out-of-bounds. 3716 // only occur only when index is out-of-bounds.
3717 __ b(deopt); 3717 __ b(deopt);
3718 return; 3718 return;
3719 } 3719 }
3720 3720
3721 intptr_t guarded_array_length = -1;
3722 if (array_ != NULL) {
3723 if (array_->guarded_list_length() >= 0) {
3724 guarded_array_length = array_->guarded_list_length();
3725 }
3726 }
3727
3728 if (index_loc.IsConstant() && guarded_array_length >= 0) {
3729 const Object& index = Smi::Cast(index_loc.constant());
3730 int32_t i = reinterpret_cast<int32_t>(index.raw());
3731 if (i >= guarded_array_length) {
3732 // We know this bounds check will trigger a deoptimization.
3733 __ b(deopt);
3734 }
3735 // Nothing to emit.
3736 return;
3737 }
3738
3721 if (index_loc.IsConstant()) { 3739 if (index_loc.IsConstant()) {
3722 Register length = length_loc.reg(); 3740 Register length = length_loc.reg();
3723 const Smi& index = Smi::Cast(index_loc.constant()); 3741 const Smi& index = Smi::Cast(index_loc.constant());
3724 __ BranchUnsignedLessEqual( 3742 __ BranchUnsignedLessEqual(
3725 length, reinterpret_cast<int32_t>(index.raw()), deopt); 3743 length, reinterpret_cast<int32_t>(index.raw()), deopt);
3726 } else if (length_loc.IsConstant()) { 3744 } else if (length_loc.IsConstant()) {
3727 const Smi& length = Smi::Cast(length_loc.constant()); 3745 const Smi& length = Smi::Cast(length_loc.constant());
3728 Register index = index_loc.reg(); 3746 Register index = index_loc.reg();
3729 __ BranchUnsignedGreaterEqual( 3747 __ BranchUnsignedGreaterEqual(
3730 index, reinterpret_cast<int32_t>(length.raw()), deopt); 3748 index, reinterpret_cast<int32_t>(length.raw()), deopt);
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
4073 compiler->GenerateCall(token_pos(), 4091 compiler->GenerateCall(token_pos(),
4074 &label, 4092 &label,
4075 PcDescriptors::kOther, 4093 PcDescriptors::kOther,
4076 locs()); 4094 locs());
4077 __ Drop(2); // Discard type arguments and receiver. 4095 __ Drop(2); // Discard type arguments and receiver.
4078 } 4096 }
4079 4097
4080 } // namespace dart 4098 } // namespace dart
4081 4099
4082 #endif // defined TARGET_ARCH_MIPS 4100 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698