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

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 10916090: Support immediate operands for array bounds checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « no previous file | 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_ia32.cc
===================================================================
--- runtime/vm/intermediate_language_ia32.cc (revision 11804)
+++ runtime/vm/intermediate_language_ia32.cc (working copy)
@@ -2225,7 +2225,17 @@
LocationSummary* CheckArrayBoundComp::MakeLocationSummary() const {
- return LocationSummary::Make(2,
+ const intptr_t kNumInputs = 2;
+ ConstantComp* constant_index = index()->definition()->AsConstant();
+ if (constant_index != NULL) {
+ const intptr_t kNumTemps = 0;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ locs->set_in(0, Location::RequiresRegister());
+ locs->set_in(1, Location::Constant(constant_index->value()));
Vyacheslav Egorov (Google) 2012/09/04 14:38:41 I recommend creating a helper RegisterOrConstant t
+ return locs;
+ }
+ return LocationSummary::Make(kNumInputs,
Location::NoLocation(),
LocationSummary::kNoCall);
}
@@ -2233,24 +2243,31 @@
void CheckArrayBoundComp::EmitNativeCode(FlowGraphCompiler* compiler) {
Register receiver = locs()->in(0).reg();
- Register index = locs()->in(1).reg();
const DeoptReasonId deopt_reason =
(array_type() == kGrowableObjectArrayCid) ?
kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray;
Label* deopt = compiler->AddDeoptStub(deopt_id(),
deopt_reason);
- switch (array_type()) {
- case kArrayCid:
- case kImmutableArrayCid:
- __ cmpl(index, FieldAddress(receiver, Array::length_offset()));
- break;
- case kGrowableObjectArrayCid:
- __ cmpl(index,
- FieldAddress(receiver, GrowableObjectArray::length_offset()));
- break;
+ ASSERT(array_type() == kArrayCid ||
+ array_type() == kImmutableArrayCid ||
+ array_type() == kGrowableObjectArrayCid);
+ intptr_t length_offset = (array_type() == kGrowableObjectArrayCid)
+ ? GrowableObjectArray::length_offset()
+ : Array::length_offset();
+
+ if (locs()->in(1).IsConstant()) {
+ const Object& constant = locs()->in(1).constant();
+ ASSERT(constant.IsSmi());
+ const int32_t imm =
+ reinterpret_cast<int32_t>(constant.raw());
+ __ cmpl(FieldAddress(receiver, length_offset), Immediate(imm));
+ __ j(BELOW_EQUAL, deopt);
+ } else {
+ Register index = locs()->in(1).reg();
+ __ cmpl(index, FieldAddress(receiver, length_offset));
+ __ j(ABOVE_EQUAL, deopt);
}
- __ j(ABOVE_EQUAL, deopt);
}
« no previous file with comments | « no previous file | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698