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

Side by Side Diff: runtime/vm/intermediate_language_x64.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_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 "lib/error.h" 10 #include "lib/error.h"
(...skipping 3911 matching lines...) Expand 10 before | Expand all | Expand 10 after
3922 __ testq(value, Immediate(kSmiTagMask)); 3922 __ testq(value, Immediate(kSmiTagMask));
3923 __ j(NOT_ZERO, deopt); 3923 __ j(NOT_ZERO, deopt);
3924 } 3924 }
3925 3925
3926 3926
3927 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { 3927 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const {
3928 const intptr_t kNumInputs = 2; 3928 const intptr_t kNumInputs = 2;
3929 const intptr_t kNumTemps = 0; 3929 const intptr_t kNumTemps = 0;
3930 LocationSummary* locs = 3930 LocationSummary* locs =
3931 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 3931 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3932 locs->set_in(0, Location::RegisterOrSmiConstant(length())); 3932 locs->set_in(locLength, Location::RegisterOrSmiConstant(length()));
3933 locs->set_in(1, Location::RegisterOrSmiConstant(index())); 3933 locs->set_in(locIndex, Location::RegisterOrSmiConstant(index()));
3934 return locs; 3934 return locs;
3935 } 3935 }
3936 3936
3937 3937
3938 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3938 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3939 Label* deopt = compiler->AddDeoptStub(deopt_id(), 3939 Label* deopt = compiler->AddDeoptStub(deopt_id(),
3940 kDeoptCheckArrayBound); 3940 kDeoptCheckArrayBound);
3941 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { 3941 if (locs()->in(locLength).IsConstant() && locs()->in(locIndex).IsConstant()) {
3942 ASSERT((Smi::Cast(locs()->in(locLength).constant()).Value() <=
3943 Smi::Cast(locs()->in(locIndex).constant()).Value()) ||
3944 (Smi::Cast(locs()->in(locIndex).constant()).Value() < 0));
3942 // Unconditionally deoptimize for constant bounds checks because they 3945 // Unconditionally deoptimize for constant bounds checks because they
3943 // only occur only when index is out-of-bounds. 3946 // only occur only when index is out-of-bounds.
3944 __ jmp(deopt); 3947 __ jmp(deopt);
3945 return; 3948 return;
3946 } 3949 }
3947 3950
3948 if (locs()->in(1).IsConstant()) { 3951 if (locs()->in(locIndex).IsConstant()) {
3949 Register length = locs()->in(0).reg(); 3952 Register length = locs()->in(locLength).reg();
3950 const Object& constant = locs()->in(1).constant(); 3953 const Object& constant = locs()->in(locIndex).constant();
3951 ASSERT(constant.IsSmi()); 3954 ASSERT(constant.IsSmi());
3952 const int64_t imm = 3955 const int64_t imm =
3953 reinterpret_cast<int64_t>(constant.raw()); 3956 reinterpret_cast<int64_t>(constant.raw());
3954 __ cmpq(length, Immediate(imm)); 3957 __ cmpq(length, Immediate(imm));
3955 __ j(BELOW_EQUAL, deopt); 3958 __ j(BELOW_EQUAL, deopt);
3956 } else if (locs()->in(0).IsConstant()) { 3959 } else if (locs()->in(locLength).IsConstant()) {
3957 ASSERT(locs()->in(0).constant().IsSmi()); 3960 ASSERT(locs()->in(locLength).constant().IsSmi());
3958 const Smi& smi_const = Smi::Cast(locs()->in(0).constant()); 3961 const Smi& smi_const = Smi::Cast(locs()->in(locLength).constant());
3959 Register index = locs()->in(1).reg(); 3962 Register index = locs()->in(locIndex).reg();
3960 __ cmpq(index, Immediate(reinterpret_cast<int64_t>(smi_const.raw()))); 3963 __ cmpq(index, Immediate(reinterpret_cast<int64_t>(smi_const.raw())));
3961 __ j(ABOVE_EQUAL, deopt); 3964 __ j(ABOVE_EQUAL, deopt);
3962 } else { 3965 } else {
3963 Register length = locs()->in(0).reg(); 3966 Register length = locs()->in(locLength).reg();
3964 Register index = locs()->in(1).reg(); 3967 Register index = locs()->in(locIndex).reg();
3965 __ cmpq(index, length); 3968 __ cmpq(index, length);
3966 __ j(ABOVE_EQUAL, deopt); 3969 __ j(ABOVE_EQUAL, deopt);
3967 } 3970 }
3968 } 3971 }
3969 3972
3970 3973
3971 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const { 3974 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const {
3972 UNIMPLEMENTED(); 3975 UNIMPLEMENTED();
3973 return NULL; 3976 return NULL;
3974 } 3977 }
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
4317 PcDescriptors::kOther, 4320 PcDescriptors::kOther,
4318 locs()); 4321 locs());
4319 __ Drop(2); // Discard type arguments and receiver. 4322 __ Drop(2); // Discard type arguments and receiver.
4320 } 4323 }
4321 4324
4322 } // namespace dart 4325 } // namespace dart
4323 4326
4324 #undef __ 4327 #undef __
4325 4328
4326 #endif // defined TARGET_ARCH_X64 4329 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/intermediate_language.h ('K') | « runtime/vm/intermediate_language_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698