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

Unified Diff: runtime/vm/intermediate_language_x64.cc

Issue 10867086: Implement array bounds checks explicitly in the optimized IL. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: fixed CanDeoptimize() Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_x64.cc
===================================================================
--- runtime/vm/intermediate_language_x64.cc (revision 11394)
+++ runtime/vm/intermediate_language_x64.cc (working copy)
@@ -826,19 +826,9 @@
Register index = locs()->in(1).reg();
Register result = locs()->out().reg();
- const DeoptReasonId deopt_reason =
- (receiver_type() == kGrowableObjectArrayCid) ?
- kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray;
-
- Label* deopt = compiler->AddDeoptStub(original()->deopt_id(),
- original()->try_index(),
- deopt_reason);
-
switch (receiver_type()) {
case kArrayCid:
case kImmutableArrayCid:
- __ cmpq(index, FieldAddress(receiver, Array::length_offset()));
- __ j(ABOVE_EQUAL, deopt);
// Note that index is Smi, i.e, times 4.
ASSERT(kSmiTagShift == 1);
__ movq(result, FieldAddress(receiver, index, TIMES_4, sizeof(RawArray)));
@@ -846,10 +836,6 @@
case kGrowableObjectArrayCid: {
Register temp = locs()->temp(0).reg();
-
- __ cmpq(index,
- FieldAddress(receiver, GrowableObjectArray::length_offset()));
- __ j(ABOVE_EQUAL, deopt);
__ movq(temp, FieldAddress(receiver, GrowableObjectArray::data_offset()));
// Note that index is Smi, i.e, times 4.
ASSERT(kSmiTagShift == 1);
@@ -874,7 +860,6 @@
locs->set_in(1, Location::RequiresRegister());
locs->set_in(2, Location::RequiresRegister());
locs->set_temp(0, Location::RequiresRegister());
- locs->set_out(Location::NoLocation());
return locs;
} else {
ASSERT(receiver_type() == kArrayCid);
@@ -890,15 +875,9 @@
Register index = locs()->in(1).reg();
Register value = locs()->in(2).reg();
- Label* deopt = compiler->AddDeoptStub(original()->deopt_id(),
- original()->try_index(),
- kDeoptStoreIndexed);
-
switch (receiver_type()) {
case kArrayCid:
case kImmutableArrayCid:
- __ cmpq(index, FieldAddress(receiver, Array::length_offset()));
- __ j(ABOVE_EQUAL, deopt);
// Note that index is Smi, i.e, times 4.
ASSERT(kSmiTagShift == 1);
if (this->value()->NeedsStoreBuffer()) {
@@ -914,9 +893,6 @@
case kGrowableObjectArrayCid: {
Register temp = locs()->temp(0).reg();
- __ cmpq(index,
- FieldAddress(receiver, GrowableObjectArray::length_offset()));
- __ j(ABOVE_EQUAL, deopt);
__ movq(temp, FieldAddress(receiver, GrowableObjectArray::data_offset()));
// Note that index is Smi, i.e, times 4.
ASSERT(kSmiTagShift == 1);
@@ -2378,6 +2354,37 @@
}
+LocationSummary* CheckArrayBoundComp::MakeLocationSummary() const {
+ return LocationSummary::Make(2,
+ Location::NoLocation(),
+ LocationSummary::kNoCall);
+}
+
+
+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(),
+ try_index(),
+ deopt_reason);
+ switch (array_type()) {
+ case kArrayCid:
+ case kImmutableArrayCid:
+ __ cmpq(index, FieldAddress(receiver, Array::length_offset()));
+ break;
+ case kGrowableObjectArrayCid:
+ __ cmpq(index,
+ FieldAddress(receiver, GrowableObjectArray::length_offset()));
+ break;
+ }
+ __ j(ABOVE_EQUAL, deopt);
+}
+
+
} // namespace dart
#undef __
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698