Chromium Code Reviews| Index: runtime/vm/flow_graph_optimizer.cc |
| =================================================================== |
| --- runtime/vm/flow_graph_optimizer.cc (revision 31125) |
| +++ runtime/vm/flow_graph_optimizer.cc (working copy) |
| @@ -3506,6 +3506,33 @@ |
| } |
| +void FlowGraphOptimizer::VisitStoreInstanceField( |
| + StoreInstanceFieldInstr* instr) { |
| + if (instr->IsUnboxedStore()) { |
| + ASSERT(instr->initialization_); |
| + // Determine if this field should be unboxed based on the usage of getter |
| + // and setter functions. |
| + const Field& field = Field::ZoneHandle(instr->field().raw()); |
| + const String& field_name = String::Handle(field.name()); |
| + class Class& owner = Class::Handle(field.owner()); |
| + const Function& getter = |
| + Function::Handle(owner.LookupGetterFunction(field_name)); |
| + const Function& setter = |
| + Function::Handle(owner.LookupSetterFunction(field_name)); |
|
srdjan
2013/12/13 22:12:06
Below is an important heuristic, add brief comment
Florian Schneider
2013/12/16 13:08:09
Done.
|
| + bool result = !getter.IsNull() |
| + && !setter.IsNull() |
| + && setter.usage_counter() > 0 |
|
srdjan
2013/12/13 18:13:17
Add parentheses here and below.
Florian Schneider
2013/12/16 13:08:09
Done.
|
| + && 10 * setter.usage_counter() > getter.usage_counter(); |
|
srdjan
2013/12/13 22:12:06
put 10 into a flag to experiment with ?
Florian Schneider
2013/12/16 13:08:09
Done.
|
| + if (!result) { |
| + field.set_is_unboxing_candidate(false); |
| + field.DeoptimizeDependentCode(); |
| + } else { |
| + FlowGraph::AddToGuardedFields(flow_graph_->guarded_fields(), &field); |
| + } |
| + } |
| +} |
| + |
| + |
| bool FlowGraphOptimizer::TryInlineInstanceSetter(InstanceCallInstr* instr, |
| const ICData& unary_ic_data) { |
| ASSERT((unary_ic_data.NumberOfChecks() > 0) && |
| @@ -3536,7 +3563,7 @@ |
| // Inline implicit instance setter. |
| const String& field_name = |
| String::Handle(Field::NameFromSetter(instr->function_name())); |
| - const Field& field = Field::Handle(GetField(class_id, field_name)); |
| + const Field& field = Field::ZoneHandle(GetField(class_id, field_name)); |
| ASSERT(!field.IsNull()); |
| if (InstanceCallNeedsClassCheck(instr)) { |
| @@ -3567,6 +3594,11 @@ |
| new Value(instr->ArgumentAt(0)), |
| new Value(instr->ArgumentAt(1)), |
| needs_store_barrier); |
| + |
| + if (store->IsUnboxedStore()) { |
| + FlowGraph::AddToGuardedFields(flow_graph_->guarded_fields(), &field); |
| + } |
| + |
| // Discard the environment from the original instruction because the store |
| // can't deoptimize. |
| instr->RemoveEnvironment(); |