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

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

Issue 14979007: - Canonicalize array bounds checks to avoid deopting when comparing (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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_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 "lib/error.h" 10 #include "lib/error.h"
(...skipping 3875 matching lines...) Expand 10 before | Expand all | Expand 10 after
3886 __ testl(value, Immediate(kSmiTagMask)); 3886 __ testl(value, Immediate(kSmiTagMask));
3887 __ j(NOT_ZERO, deopt); 3887 __ j(NOT_ZERO, deopt);
3888 } 3888 }
3889 3889
3890 3890
3891 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { 3891 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const {
3892 const intptr_t kNumInputs = 2; 3892 const intptr_t kNumInputs = 2;
3893 const intptr_t kNumTemps = 0; 3893 const intptr_t kNumTemps = 0;
3894 LocationSummary* locs = 3894 LocationSummary* locs =
3895 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 3895 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3896 locs->set_in(0, Location::RegisterOrSmiConstant(length())); 3896 locs->set_in(locLength, Location::RegisterOrSmiConstant(length()));
3897 locs->set_in(1, Location::RegisterOrSmiConstant(index())); 3897 locs->set_in(locIndex, Location::RegisterOrSmiConstant(index()));
3898 return locs; 3898 return locs;
3899 } 3899 }
3900 3900
3901 3901
3902 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3902 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3903 Label* deopt = compiler->AddDeoptStub(deopt_id(), 3903 Label* deopt = compiler->AddDeoptStub(deopt_id(),
3904 kDeoptCheckArrayBound); 3904 kDeoptCheckArrayBound);
3905 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { 3905 if (locs()->in(locLength).IsConstant() && locs()->in(locIndex).IsConstant()) {
3906 ASSERT((Smi::Cast(locs()->in(locLength).constant()).Value() <=
3907 Smi::Cast(locs()->in(locIndex).constant()).Value()) ||
3908 (Smi::Cast(locs()->in(locIndex).constant()).Value() < 0));
3906 // Unconditionally deoptimize for constant bounds checks because they 3909 // Unconditionally deoptimize for constant bounds checks because they
3907 // only occur only when index is out-of-bounds. 3910 // only occur only when index is out-of-bounds.
3908 __ jmp(deopt); 3911 __ jmp(deopt);
3909 return; 3912 return;
3910 } 3913 }
3911 3914
3912 if (locs()->in(1).IsConstant()) { 3915 if (locs()->in(locIndex).IsConstant()) {
3913 Register length = locs()->in(0).reg(); 3916 Register length = locs()->in(locLength).reg();
3914 const Object& constant = locs()->in(1).constant(); 3917 const Object& constant = locs()->in(locIndex).constant();
3915 ASSERT(constant.IsSmi()); 3918 ASSERT(constant.IsSmi());
3916 const int32_t imm = 3919 const int32_t imm =
3917 reinterpret_cast<int32_t>(constant.raw()); 3920 reinterpret_cast<int32_t>(constant.raw());
3918 __ cmpl(length, Immediate(imm)); 3921 __ cmpl(length, Immediate(imm));
3919 __ j(BELOW_EQUAL, deopt); 3922 __ j(BELOW_EQUAL, deopt);
3920 } else if (locs()->in(0).IsConstant()) { 3923 } else if (locs()->in(locLength).IsConstant()) {
3921 ASSERT(locs()->in(0).constant().IsSmi()); 3924 ASSERT(locs()->in(locLength).constant().IsSmi());
3922 const Smi& smi_const = Smi::Cast(locs()->in(0).constant()); 3925 const Smi& smi_const = Smi::Cast(locs()->in(locLength).constant());
3923 Register index = locs()->in(1).reg(); 3926 Register index = locs()->in(locIndex).reg();
3924 __ cmpl(index, Immediate(reinterpret_cast<int32_t>(smi_const.raw()))); 3927 __ cmpl(index, Immediate(reinterpret_cast<int32_t>(smi_const.raw())));
3925 __ j(ABOVE_EQUAL, deopt); 3928 __ j(ABOVE_EQUAL, deopt);
3926 } else { 3929 } else {
3927 Register length = locs()->in(0).reg(); 3930 Register length = locs()->in(locLength).reg();
3928 Register index = locs()->in(1).reg(); 3931 Register index = locs()->in(locIndex).reg();
3929 __ cmpl(index, length); 3932 __ cmpl(index, length);
3930 __ j(ABOVE_EQUAL, deopt); 3933 __ j(ABOVE_EQUAL, deopt);
3931 } 3934 }
3932 } 3935 }
3933 3936
3934 3937
3935 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const { 3938 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const {
3936 const intptr_t kNumInputs = 1; 3939 const intptr_t kNumInputs = 1;
3937 const intptr_t value_cid = value()->Type()->ToCid(); 3940 const intptr_t value_cid = value()->Type()->ToCid();
3938 const bool needs_temp = ((value_cid != kSmiCid) && (value_cid != kMintCid)); 3941 const bool needs_temp = ((value_cid != kSmiCid) && (value_cid != kMintCid));
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
4674 PcDescriptors::kOther, 4677 PcDescriptors::kOther,
4675 locs()); 4678 locs());
4676 __ Drop(2); // Discard type arguments and receiver. 4679 __ Drop(2); // Discard type arguments and receiver.
4677 } 4680 }
4678 4681
4679 } // namespace dart 4682 } // namespace dart
4680 4683
4681 #undef __ 4684 #undef __
4682 4685
4683 #endif // defined TARGET_ARCH_IA32 4686 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698