| 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 2757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2768 } | 2768 } |
| 2769 } | 2769 } |
| 2770 } | 2770 } |
| 2771 } | 2771 } |
| 2772 } | 2772 } |
| 2773 | 2773 |
| 2774 | 2774 |
| 2775 void JitOptimizer::VisitStoreInstanceField( | 2775 void JitOptimizer::VisitStoreInstanceField( |
| 2776 StoreInstanceFieldInstr* instr) { | 2776 StoreInstanceFieldInstr* instr) { |
| 2777 if (instr->IsUnboxedStore()) { | 2777 if (instr->IsUnboxedStore()) { |
| 2778 ASSERT(instr->is_potential_unboxed_initialization_); | 2778 ASSERT(instr->is_initialization()); |
| 2779 // Determine if this field should be unboxed based on the usage of getter | 2779 // Determine if this field should be unboxed based on the usage of getter |
| 2780 // and setter functions: The heuristic requires that the setter has a | 2780 // and setter functions: The heuristic requires that the setter has a |
| 2781 // usage count of at least 1/kGetterSetterRatio of the getter usage count. | 2781 // usage count of at least 1/kGetterSetterRatio of the getter usage count. |
| 2782 // This is to avoid unboxing fields where the setter is never or rarely | 2782 // This is to avoid unboxing fields where the setter is never or rarely |
| 2783 // executed. | 2783 // executed. |
| 2784 const Field& field = instr->field(); | 2784 const Field& field = instr->field(); |
| 2785 const String& field_name = String::Handle(Z, field.name()); | 2785 const String& field_name = String::Handle(Z, field.name()); |
| 2786 const Class& owner = Class::Handle(Z, field.Owner()); | 2786 const Class& owner = Class::Handle(Z, field.Owner()); |
| 2787 const Function& getter = | 2787 const Function& getter = |
| 2788 Function::Handle(Z, owner.LookupGetterFunction(field_name)); | 2788 Function::Handle(Z, owner.LookupGetterFunction(field_name)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2837 instr->ReplaceWith(replacement, current_iterator()); | 2837 instr->ReplaceWith(replacement, current_iterator()); |
| 2838 | 2838 |
| 2839 StoreInstanceFieldInstr* store = | 2839 StoreInstanceFieldInstr* store = |
| 2840 new(Z) StoreInstanceFieldInstr(Context::parent_offset(), | 2840 new(Z) StoreInstanceFieldInstr(Context::parent_offset(), |
| 2841 new Value(replacement), | 2841 new Value(replacement), |
| 2842 new Value(flow_graph_->constant_null()), | 2842 new Value(flow_graph_->constant_null()), |
| 2843 kNoStoreBarrier, | 2843 kNoStoreBarrier, |
| 2844 instr->token_pos()); | 2844 instr->token_pos()); |
| 2845 // Storing into uninitialized memory; remember to prevent dead store | 2845 // Storing into uninitialized memory; remember to prevent dead store |
| 2846 // elimination and ensure proper GC barrier. | 2846 // elimination and ensure proper GC barrier. |
| 2847 store->set_is_object_reference_initialization(true); | 2847 store->set_is_initialization(true); |
| 2848 flow_graph_->InsertAfter(replacement, store, NULL, FlowGraph::kEffect); | 2848 flow_graph_->InsertAfter(replacement, store, NULL, FlowGraph::kEffect); |
| 2849 Definition* cursor = store; | 2849 Definition* cursor = store; |
| 2850 for (intptr_t i = 0; i < instr->num_context_variables(); ++i) { | 2850 for (intptr_t i = 0; i < instr->num_context_variables(); ++i) { |
| 2851 store = | 2851 store = |
| 2852 new(Z) StoreInstanceFieldInstr(Context::variable_offset(i), | 2852 new(Z) StoreInstanceFieldInstr(Context::variable_offset(i), |
| 2853 new Value(replacement), | 2853 new Value(replacement), |
| 2854 new Value(flow_graph_->constant_null()), | 2854 new Value(flow_graph_->constant_null()), |
| 2855 kNoStoreBarrier, | 2855 kNoStoreBarrier, |
| 2856 instr->token_pos()); | 2856 instr->token_pos()); |
| 2857 // Storing into uninitialized memory; remember to prevent dead store | 2857 // Storing into uninitialized memory; remember to prevent dead store |
| 2858 // elimination and ensure proper GC barrier. | 2858 // elimination and ensure proper GC barrier. |
| 2859 store->set_is_object_reference_initialization(true); | 2859 store->set_is_initialization(true); |
| 2860 flow_graph_->InsertAfter(cursor, store, NULL, FlowGraph::kEffect); | 2860 flow_graph_->InsertAfter(cursor, store, NULL, FlowGraph::kEffect); |
| 2861 cursor = store; | 2861 cursor = store; |
| 2862 } | 2862 } |
| 2863 } | 2863 } |
| 2864 | 2864 |
| 2865 | 2865 |
| 2866 void JitOptimizer::VisitLoadCodeUnits(LoadCodeUnitsInstr* instr) { | 2866 void JitOptimizer::VisitLoadCodeUnits(LoadCodeUnitsInstr* instr) { |
| 2867 // TODO(zerny): Use kUnboxedUint32 once it is fully supported/optimized. | 2867 // TODO(zerny): Use kUnboxedUint32 once it is fully supported/optimized. |
| 2868 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) | 2868 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) |
| 2869 if (!instr->can_pack_into_smi()) | 2869 if (!instr->can_pack_into_smi()) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2946 | 2946 |
| 2947 // Discard the environment from the original instruction because the store | 2947 // Discard the environment from the original instruction because the store |
| 2948 // can't deoptimize. | 2948 // can't deoptimize. |
| 2949 instr->RemoveEnvironment(); | 2949 instr->RemoveEnvironment(); |
| 2950 ReplaceCall(instr, store); | 2950 ReplaceCall(instr, store); |
| 2951 return true; | 2951 return true; |
| 2952 } | 2952 } |
| 2953 | 2953 |
| 2954 | 2954 |
| 2955 } // namespace dart | 2955 } // namespace dart |
| OLD | NEW |