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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 23003026: Avoid array bounds check when allowed by guarded field. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « no previous file | runtime/vm/intermediate_language.h » ('j') | runtime/vm/intermediate_language_arm.cc » ('J')
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 ba9a4d9fa9dbe68442e61735fcc7bd37da568e57..b2fc5b6ee596759c38c9a29df30d17651b045fd2 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -770,6 +770,13 @@ intptr_t FlowGraphOptimizer::PrepareIndexedOp(InstanceCallInstr* call,
call->env(),
Definition::kEffect);
+ // Get the field if the array is loaded from a class field.
+ const Field* field = NULL;
+ if ((*array)->IsLoadField()) {
+ LoadFieldInstr* load_field_instr = (*array)->AsLoadField();
+ field = load_field_instr->field();
+ }
+
// Insert array length load and bounds check.
const bool is_immutable =
CheckArrayBoundInstr::IsFixedLengthArrayType(class_id);
@@ -783,7 +790,8 @@ intptr_t FlowGraphOptimizer::PrepareIndexedOp(InstanceCallInstr* call,
LoadFieldInstr::RecognizedKindFromArrayCid(class_id));
InsertBefore(call, length, NULL, Definition::kValue);
InsertBefore(call,
- new CheckArrayBoundInstr(new Value(length),
+ new CheckArrayBoundInstr(field,
+ new Value(length),
new Value(*index),
call->deopt_id()),
call->env(),
@@ -1688,7 +1696,8 @@ LoadIndexedInstr* FlowGraphOptimizer::BuildStringCodeUnitAt(
LoadFieldInstr* length = BuildLoadStringLength(str);
InsertBefore(call, length, NULL, Definition::kValue);
InsertBefore(call,
- new CheckArrayBoundInstr(new Value(length),
+ new CheckArrayBoundInstr(NULL,
+ new Value(length),
new Value(index),
call->deopt_id()),
call->env(),
@@ -2461,7 +2470,8 @@ void FlowGraphOptimizer::PrepareByteArrayViewOp(
// Check byte_index < len_in_bytes.
InsertBefore(call,
- new CheckArrayBoundInstr(new Value(len_in_bytes),
+ new CheckArrayBoundInstr(NULL,
+ new Value(len_in_bytes),
new Value(byte_index),
call->deopt_id()),
call->env(),
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | runtime/vm/intermediate_language_arm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698