Index: runtime/vm/flow_graph_optimizer.cc |
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc |
index 2b7eecc01579dd628e0973ae19db35e9fd6ac02c..682ca1443cdf1d1ff10b7d1b7b333dd45b9dd0eb 100644 |
--- a/runtime/vm/flow_graph_optimizer.cc |
+++ b/runtime/vm/flow_graph_optimizer.cc |
@@ -915,7 +915,8 @@ void FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call) { |
void FlowGraphOptimizer::InlineArrayLengthGetter(InstanceCallInstr* call, |
intptr_t length_offset, |
- bool is_immutable) { |
+ bool is_immutable, |
+ MethodRecognizer::Kind kind) { |
// Check receiver class. |
AddCheckClass(call, call->ArgumentAt(0)->value()->Copy()); |
@@ -925,6 +926,7 @@ void FlowGraphOptimizer::InlineArrayLengthGetter(InstanceCallInstr* call, |
Type::ZoneHandle(Type::SmiType()), |
is_immutable); |
load->set_result_cid(kSmiCid); |
+ load->set_recognized_kind(kind); |
call->ReplaceWith(load, current_iterator()); |
RemovePushArguments(call); |
} |
@@ -947,6 +949,7 @@ void FlowGraphOptimizer::InlineGArrayCapacityGetter(InstanceCallInstr* call) { |
Array::length_offset(), |
Type::ZoneHandle(Type::SmiType())); |
length_load->set_result_cid(kSmiCid); |
+ length_load->set_recognized_kind(MethodRecognizer::kObjectArrayLength); |
call->ReplaceWith(length_load, current_iterator()); |
RemovePushArguments(call); |
@@ -1027,12 +1030,16 @@ bool FlowGraphOptimizer::TryInlineInstanceGetter(InstanceCallInstr* call) { |
switch (recognized_kind) { |
case MethodRecognizer::kObjectArrayLength: |
case MethodRecognizer::kImmutableArrayLength: |
- InlineArrayLengthGetter(call, Array::length_offset(), true); |
+ InlineArrayLengthGetter(call, |
+ Array::length_offset(), |
+ true, |
+ recognized_kind); |
break; |
case MethodRecognizer::kGrowableArrayLength: |
InlineArrayLengthGetter(call, |
GrowableObjectArray::length_offset(), |
- false); |
+ false, |
+ recognized_kind); |
break; |
default: |
UNREACHABLE(); |
@@ -2100,11 +2107,16 @@ void RangeAnalysis::InferRangesRecursive(BlockEntryInstr* block) { |
} |
for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { |
- Definition* defn = it.Current()->AsDefinition(); |
+ Instruction* current = it.Current(); |
+ |
+ Definition* defn = current->AsDefinition(); |
if ((defn != NULL) && |
(defn->ssa_temp_index() != -1) && |
smi_definitions_->Contains(defn->ssa_temp_index())) { |
defn->InferRange(); |
+ } else if (current->IsCheckArrayBound() && |
+ current->AsCheckArrayBound()->IsRedundant()) { |
+ it.RemoveCurrentFromGraph(); |
} |
} |