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

Unified Diff: runtime/vm/intermediate_language_mips.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_mips.cc
===================================================================
--- runtime/vm/intermediate_language_mips.cc (revision 22689)
+++ runtime/vm/intermediate_language_mips.cc (working copy)
@@ -2480,37 +2480,41 @@
const intptr_t kNumTemps = 0;
LocationSummary* locs =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
- locs->set_in(0, Location::RegisterOrSmiConstant(length()));
- locs->set_in(1, Location::RegisterOrSmiConstant(index()));
+ locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length()));
+ locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index()));
return locs;
}
void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- Label* deopt = compiler->AddDeoptStub(deopt_id(),
- kDeoptCheckArrayBound);
- if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) {
+ Label* deopt = compiler->AddDeoptStub(deopt_id(), kDeoptCheckArrayBound);
+
+ Location length_loc = locs()->in(kLengthPos);
+ Location index_loc = locs()->in(kIndexPos);
+
+ if (length_loc.IsConstant() && index_loc.IsConstant()) {
+ ASSERT((Smi::Cast(length_loc.constant()).Value() <=
+ Smi::Cast(index_loc.constant()).Value()) ||
+ (Smi::Cast(index_loc.constant()).Value() < 0));
// Unconditionally deoptimize for constant bounds checks because they
// only occur only when index is out-of-bounds.
__ b(deopt);
return;
}
- if (locs()->in(1).IsConstant()) {
- Register length = locs()->in(0).reg();
- const Object& constant = locs()->in(1).constant();
- ASSERT(constant.IsSmi());
+ if (index_loc.IsConstant()) {
+ Register length = length_loc.reg();
+ const Smi& index = Smi::Cast(index_loc.constant());
__ BranchUnsignedLessEqual(
- length, reinterpret_cast<int32_t>(constant.raw()), deopt);
- } else if (locs()->in(0).IsConstant()) {
- ASSERT(locs()->in(0).constant().IsSmi());
- const Smi& smi_const = Smi::Cast(locs()->in(0).constant());
- Register index = locs()->in(1).reg();
+ length, reinterpret_cast<int32_t>(index.raw()), deopt);
+ } else if (length_loc.IsConstant()) {
+ const Smi& length = Smi::Cast(length_loc.constant());
+ Register index = index_loc.reg();
__ BranchUnsignedGreaterEqual(
- index, reinterpret_cast<int32_t>(smi_const.raw()), deopt);
+ index, reinterpret_cast<int32_t>(length.raw()), deopt);
} else {
- Register length = locs()->in(0).reg();
- Register index = locs()->in(1).reg();
+ Register length = length_loc.reg();
+ Register index = index_loc.reg();
__ BranchUnsignedGreaterEqual(index, length, deopt);
}
}
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698