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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 23584002: Replace guarded list length field loads with constants (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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.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
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index d301900c6182f698f606b26f2e2c880fa8712066..53f44506c69e60afd150f7d538e0eb263949024f 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -770,51 +770,24 @@ intptr_t FlowGraphOptimizer::PrepareIndexedOp(InstanceCallInstr* call,
call->env(),
Definition::kEffect);
- bool emit_bounds_check = true;
- // Get the field for the array.
- const Field* field = NULL;
- if ((*array)->IsLoadField()) {
- LoadFieldInstr* load_field_instr = (*array)->AsLoadField();
- field = load_field_instr->field();
- }
- // Extract the guarded array length.
- intptr_t guarded_array_length = -1;
- if (field != NULL) {
- if (field->guarded_list_length() >= 0) {
- guarded_array_length = field->guarded_list_length();
- }
- }
- Definition* i = *index;
- // Check if we can skip emitting the bounds check.
- if (i->IsConstant() && guarded_array_length >= 0) {
- ConstantInstr* constant = i->AsConstant();
- ASSERT(constant != NULL);
- intptr_t ci = Smi::Cast(constant->value()).Value();
- if (ci < guarded_array_length) {
- emit_bounds_check = false;
- }
- }
-
- if (emit_bounds_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);
- InsertBefore(call,
- new CheckArrayBoundInstr(new Value(length),
- new Value(*index),
- call->deopt_id()),
- call->env(),
- Definition::kEffect);
- }
+ // 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),
+ call->deopt_id()),
+ call->env(),
+ Definition::kEffect);
if (class_id == kGrowableObjectArrayCid) {
« 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