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

Unified Diff: runtime/vm/intermediate_language_x64.cc

Issue 10911277: Optimize code for bound checks if array is constant. Skip unnecessary Smi checks if they still surv… (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 | « runtime/vm/intermediate_language_ia32.cc ('k') | tests/language/optimized_lists.dart » ('j') | 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 12301)
+++ runtime/vm/intermediate_language_x64.cc (working copy)
@@ -2230,6 +2230,10 @@
LocationSummary* CheckSmiInstr::MakeLocationSummary() const {
+ // TODO(srdjan): Check if we can remove this by reordering CSE and LICM.
+ if (value()->ResultCid() == kSmiCid) {
+ return new LocationSummary(0, 0, LocationSummary::kNoCall);
+ }
const intptr_t kNumInputs = 1;
const intptr_t kNumTemps = 0;
LocationSummary* summary =
@@ -2240,6 +2244,8 @@
void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ // TODO(srdjan): Check if we can remove this by reordering CSE and LICM.
+ if (value()->ResultCid() == kSmiCid) return;
Register value = locs()->in(0).reg();
Label* deopt = compiler->AddDeoptStub(deopt_id(),
kDeoptCheckSmi);
@@ -2260,8 +2266,6 @@
void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- Register receiver = locs()->in(0).reg();
-
const DeoptReasonId deopt_reason =
(array_type() == kGrowableObjectArrayCid) ?
kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray;
@@ -2274,14 +2278,26 @@
? GrowableObjectArray::length_offset()
: Array::length_offset();
+ // This case should not have created a bound check instruction.
+ ASSERT(!(locs()->in(0).IsConstant() && locs()->in(1).IsConstant()));
+
if (locs()->in(1).IsConstant()) {
+ Register receiver = locs()->in(0).reg();
const Object& constant = locs()->in(1).constant();
ASSERT(constant.IsSmi());
const int64_t imm =
reinterpret_cast<int64_t>(constant.raw());
__ cmpq(FieldAddress(receiver, length_offset), Immediate(imm));
__ j(BELOW_EQUAL, deopt);
+ } else if (locs()->in(0).IsConstant()) {
+ const Object& constant = locs()->in(0).constant();
+ ASSERT(constant.IsArray());
+ const Array& array = Array::Cast(constant);
+ Register index = locs()->in(1).reg();
+ __ cmpq(index, Immediate(array.Length()));
+ __ j(ABOVE_EQUAL, deopt);
} else {
+ Register receiver = locs()->in(0).reg();
Register index = locs()->in(1).reg();
__ cmpq(index, FieldAddress(receiver, length_offset));
__ j(ABOVE_EQUAL, deopt);
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | tests/language/optimized_lists.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698