| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/jit_optimizer.h" | 5 #include "vm/jit_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/branch_optimizer.h" | 8 #include "vm/branch_optimizer.h" |
| 9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 2899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2910 | 2910 |
| 2911 void JitOptimizer::VisitStoreInstanceField( | 2911 void JitOptimizer::VisitStoreInstanceField( |
| 2912 StoreInstanceFieldInstr* instr) { | 2912 StoreInstanceFieldInstr* instr) { |
| 2913 if (instr->IsUnboxedStore()) { | 2913 if (instr->IsUnboxedStore()) { |
| 2914 ASSERT(instr->is_potential_unboxed_initialization_); | 2914 ASSERT(instr->is_potential_unboxed_initialization_); |
| 2915 // Determine if this field should be unboxed based on the usage of getter | 2915 // Determine if this field should be unboxed based on the usage of getter |
| 2916 // and setter functions: The heuristic requires that the setter has a | 2916 // and setter functions: The heuristic requires that the setter has a |
| 2917 // usage count of at least 1/kGetterSetterRatio of the getter usage count. | 2917 // usage count of at least 1/kGetterSetterRatio of the getter usage count. |
| 2918 // This is to avoid unboxing fields where the setter is never or rarely | 2918 // This is to avoid unboxing fields where the setter is never or rarely |
| 2919 // executed. | 2919 // executed. |
| 2920 const Field& field = Field::ZoneHandle(Z, instr->field().Original()); | 2920 const Field& field = instr->field(); |
| 2921 const String& field_name = String::Handle(Z, field.name()); | 2921 const String& field_name = String::Handle(Z, field.name()); |
| 2922 const Class& owner = Class::Handle(Z, field.Owner()); | 2922 const Class& owner = |
| 2923 Class::Handle(Z, Field::Handle(Z, field.Original()).Owner()); |
| 2923 const Function& getter = | 2924 const Function& getter = |
| 2924 Function::Handle(Z, owner.LookupGetterFunction(field_name)); | 2925 Function::Handle(Z, owner.LookupGetterFunction(field_name)); |
| 2925 const Function& setter = | 2926 const Function& setter = |
| 2926 Function::Handle(Z, owner.LookupSetterFunction(field_name)); | 2927 Function::Handle(Z, owner.LookupSetterFunction(field_name)); |
| 2927 bool unboxed_field = false; | 2928 bool unboxed_field = false; |
| 2928 if (!getter.IsNull() && !setter.IsNull()) { | 2929 if (!getter.IsNull() && !setter.IsNull()) { |
| 2929 if (field.is_double_initialized()) { | 2930 if (field.is_double_initialized()) { |
| 2930 unboxed_field = true; | 2931 unboxed_field = true; |
| 2931 } else if ((setter.usage_counter() > 0) && | 2932 } else if ((setter.usage_counter() > 0) && |
| 2932 ((FLAG_getter_setter_ratio * setter.usage_counter()) >= | 2933 ((FLAG_getter_setter_ratio * setter.usage_counter()) >= |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2947 } | 2948 } |
| 2948 if (FLAG_trace_optimization || FLAG_trace_field_guards) { | 2949 if (FLAG_trace_optimization || FLAG_trace_field_guards) { |
| 2949 THR_Print("Disabling unboxing of %s\n", field.ToCString()); | 2950 THR_Print("Disabling unboxing of %s\n", field.ToCString()); |
| 2950 if (!setter.IsNull()) { | 2951 if (!setter.IsNull()) { |
| 2951 OS::Print(" setter usage count: %" Pd "\n", setter.usage_counter()); | 2952 OS::Print(" setter usage count: %" Pd "\n", setter.usage_counter()); |
| 2952 } | 2953 } |
| 2953 if (!getter.IsNull()) { | 2954 if (!getter.IsNull()) { |
| 2954 OS::Print(" getter usage count: %" Pd "\n", getter.usage_counter()); | 2955 OS::Print(" getter usage count: %" Pd "\n", getter.usage_counter()); |
| 2955 } | 2956 } |
| 2956 } | 2957 } |
| 2958 ASSERT(field.IsOriginal()); |
| 2957 field.set_is_unboxing_candidate(false); | 2959 field.set_is_unboxing_candidate(false); |
| 2958 field.DeoptimizeDependentCode(); | 2960 field.DeoptimizeDependentCode(); |
| 2959 } else { | 2961 } else { |
| 2960 flow_graph()->parsed_function().AddToGuardedFields(&field); | 2962 flow_graph()->parsed_function().AddToGuardedFields(&field); |
| 2961 } | 2963 } |
| 2962 } | 2964 } |
| 2963 } | 2965 } |
| 2964 | 2966 |
| 2965 | 2967 |
| 2966 void JitOptimizer::VisitAllocateContext(AllocateContextInstr* instr) { | 2968 void JitOptimizer::VisitAllocateContext(AllocateContextInstr* instr) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3081 | 3083 |
| 3082 // Discard the environment from the original instruction because the store | 3084 // Discard the environment from the original instruction because the store |
| 3083 // can't deoptimize. | 3085 // can't deoptimize. |
| 3084 instr->RemoveEnvironment(); | 3086 instr->RemoveEnvironment(); |
| 3085 ReplaceCall(instr, store); | 3087 ReplaceCall(instr, store); |
| 3086 return true; | 3088 return true; |
| 3087 } | 3089 } |
| 3088 | 3090 |
| 3089 | 3091 |
| 3090 } // namespace dart | 3092 } // namespace dart |
| OLD | NEW |