Chromium Code Reviews| Index: runtime/vm/flow_graph_optimizer.cc |
| diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc |
| index f89f0d287a5f10291ce2f0e0fb4b0d74ee58ae33..7c9e56aed0e2204341a4bce0bb91e50d8328302b 100644 |
| --- a/runtime/vm/flow_graph_optimizer.cc |
| +++ b/runtime/vm/flow_graph_optimizer.cc |
| @@ -1233,6 +1233,12 @@ void FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call) { |
| field.Offset(), |
| AbstractType::ZoneHandle(field.type()), |
| field.is_final()); |
| + if (field.guarded_cid() != kIllegalCid) { |
| + load->set_result_cid(field.GuardedCid()); |
| + load->set_field(&Field::ZoneHandle(field.raw())); |
| + } |
| + load->set_field_name(String::Handle(field.name()).ToCString()); |
| + |
| // Discard the environment from the original instruction because the load |
| // can't deoptimize. |
| call->RemoveEnvironment(); |
| @@ -1876,6 +1882,25 @@ void FlowGraphOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) { |
| } |
| +void FlowGraphOptimizer::VisitStoreInstanceField( |
| + StoreInstanceFieldInstr* instr) { |
| + if (!instr->should_emit_field_guard()) return; |
| + |
| + if (instr->field().guarded_cid() != kDynamicCid) { |
|
Kevin Millikin (Google)
2013/03/12 12:14:56
I think it's a bit better to always insert the gua
Vyacheslav Egorov (Google)
2013/03/12 16:54:40
Done. Though it requires an expression temp to pre
|
| + ASSERT(instr->env() != NULL); |
| + // TODO(vegorov) need a deopt id here! |
| + InsertBefore(instr, |
| + new GuardFieldInstr(instr->value()->Copy(), |
| + instr->field(), |
| + instr->deopt_id()), |
| + instr->env(), |
| + Definition::kEffect); |
| + } |
| + |
| + instr->detach_field_guard(); |
| +} |
| + |
| + |
| // Tries to optimize instance call by replacing it with a faster instruction |
| // (e.g, binary op, field load, ..). |
| void FlowGraphOptimizer::VisitInstanceCall(InstanceCallInstr* instr) { |
| @@ -2016,11 +2041,24 @@ bool FlowGraphOptimizer::TryInlineInstanceSetter(InstanceCallInstr* instr, |
| Definition::kEffect); |
| needs_store_barrier = kNoStoreBarrier; |
| } |
| + |
| + if (field.guarded_cid() != kDynamicCid) { |
| + InsertBefore(instr, |
| + new GuardFieldInstr(new Value(instr->ArgumentAt(1)), |
| + field, |
| + instr->deopt_id()), |
| + instr->env(), |
| + Definition::kEffect); |
| + } |
| + |
| + // Field guard was detached. |
| + const bool needs_field_guard = false; |
| StoreInstanceFieldInstr* store = new StoreInstanceFieldInstr( |
| field, |
| new Value(instr->ArgumentAt(0)), |
| new Value(instr->ArgumentAt(1)), |
| - needs_store_barrier); |
| + needs_store_barrier, |
| + needs_field_guard); |
| // Discard the environment from the original instruction because the store |
| // can't deoptimize. |
| instr->RemoveEnvironment(); |
| @@ -3777,6 +3815,7 @@ void ConstantPropagator::VisitCheckStackOverflow( |
| void ConstantPropagator::VisitCheckClass(CheckClassInstr* instr) { } |
| +void ConstantPropagator::VisitGuardField(GuardFieldInstr* instr) { } |
| void ConstantPropagator::VisitCheckSmi(CheckSmiInstr* instr) { } |