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

Unified Diff: runtime/vm/flow_graph_optimizer.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 | « no previous file | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 12301)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -363,14 +363,19 @@
new CheckSmiInstr(index->Copy(), call->deopt_id()),
call->env(),
Definition::kEffect);
- // Insert array bounds check.
- InsertBefore(call,
- new CheckArrayBoundInstr(array->Copy(),
- index->Copy(),
- class_id,
- call),
- call->env(),
- Definition::kEffect);
+ // If both index and array are constants, then the bound check always
+ // succeeded.
+ // TODO(srdjan): Remove once constant propagation lands.
+ if (!(array->BindsToConstant() && index->BindsToConstant())) {
+ // Insert array bounds check.
+ InsertBefore(call,
+ new CheckArrayBoundInstr(array->Copy(),
+ index->Copy(),
+ class_id,
+ call),
+ call->env(),
+ Definition::kEffect);
+ }
if (class_id == kGrowableObjectArrayCid) {
// Insert data elements load.
LoadFieldInstr* elements =
« no previous file with comments | « no previous file | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698