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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 14566020: - Correctly handle negative constant indices when (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 | « no previous file | runtime/vm/intermediate_language.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 22702)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -691,38 +691,26 @@
call->env(),
Definition::kEffect);
- // If both index and array are constants, then do a compile-time check.
- // TODO(srdjan): Remove once constant propagation handles bounds checks.
- bool skip_check = false;
- if ((*array)->IsConstant() && (*index)->IsConstant()) {
- const ImmutableArray& constant_array =
- ImmutableArray::Cast((*array)->AsConstant()->value());
- const Object& constant_index = (*index)->AsConstant()->value();
- skip_check = constant_index.IsSmi() &&
- (Smi::Cast(constant_index).Value() < constant_array.Length());
- }
- if (!skip_check) {
- // Insert array length load and bounds check.
- const bool is_immutable =
- CheckArrayBoundInstr::IsFixedLengthArrayType(class_id);
- LoadFieldInstr* length =
- new LoadFieldInstr(new Value(*array),
- CheckArrayBoundInstr::LengthOffsetFor(class_id),
- Type::ZoneHandle(Type::SmiType()),
- is_immutable);
- length->set_result_cid(kSmiCid);
- length->set_recognized_kind(
- LoadFieldInstr::RecognizedKindFromArrayCid(class_id));
- InsertBefore(call, length, NULL, Definition::kValue);
+ // Insert array length load and bounds check.
+ const bool is_immutable =
+ CheckArrayBoundInstr::IsFixedLengthArrayType(class_id);
+ LoadFieldInstr* length =
+ new LoadFieldInstr(new Value(*array),
+ CheckArrayBoundInstr::LengthOffsetFor(class_id),
+ Type::ZoneHandle(Type::SmiType()),
+ is_immutable);
+ length->set_result_cid(kSmiCid);
+ length->set_recognized_kind(
+ LoadFieldInstr::RecognizedKindFromArrayCid(class_id));
+ InsertBefore(call, length, NULL, Definition::kValue);
+ InsertBefore(call,
+ new CheckArrayBoundInstr(new Value(length),
+ new Value(*index),
+ class_id,
+ call),
+ call->env(),
+ Definition::kEffect);
- InsertBefore(call,
- new CheckArrayBoundInstr(new Value(length),
- new Value(*index),
- 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.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698