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/aot_optimizer.h" | 5 #include "vm/aot_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 2694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2705 default: | 2705 default: |
2706 break; | 2706 break; |
2707 } | 2707 } |
2708 } | 2708 } |
2709 } | 2709 } |
2710 } | 2710 } |
2711 } | 2711 } |
2712 } | 2712 } |
2713 | 2713 |
2714 | 2714 |
2715 void AotOptimizer::VisitAllocateContext(AllocateContextInstr* instr) { | |
2716 // Replace generic allocation with a sequence of inlined allocation and | |
2717 // explicit initalizing stores. | |
2718 AllocateUninitializedContextInstr* replacement = | |
2719 new AllocateUninitializedContextInstr(instr->token_pos(), | |
2720 instr->num_context_variables()); | |
2721 instr->ReplaceWith(replacement, current_iterator()); | |
2722 | |
2723 StoreInstanceFieldInstr* store = | |
2724 new(Z) StoreInstanceFieldInstr(Context::parent_offset(), | |
2725 new Value(replacement), | |
2726 new Value(flow_graph_->constant_null()), | |
2727 kNoStoreBarrier, | |
2728 instr->token_pos()); | |
2729 // Storing into uninitialized memory; remember to prevent dead store | |
2730 // elimination and ensure proper GC barrier. | |
2731 store->set_is_object_reference_initialization(true); | |
2732 flow_graph_->InsertAfter(replacement, store, NULL, FlowGraph::kEffect); | |
2733 Definition* cursor = store; | |
2734 for (intptr_t i = 0; i < instr->num_context_variables(); ++i) { | |
2735 store = | |
2736 new(Z) StoreInstanceFieldInstr(Context::variable_offset(i), | |
2737 new Value(replacement), | |
2738 new Value(flow_graph_->constant_null()), | |
2739 kNoStoreBarrier, | |
2740 instr->token_pos()); | |
2741 // Storing into uninitialized memory; remember to prevent dead store | |
2742 // elimination and ensure proper GC barrier. | |
2743 store->set_is_object_reference_initialization(true); | |
2744 flow_graph_->InsertAfter(cursor, store, NULL, FlowGraph::kEffect); | |
2745 cursor = store; | |
2746 } | |
2747 } | |
2748 | |
2749 | |
2750 void AotOptimizer::VisitLoadCodeUnits(LoadCodeUnitsInstr* instr) { | 2715 void AotOptimizer::VisitLoadCodeUnits(LoadCodeUnitsInstr* instr) { |
2751 // TODO(zerny): Use kUnboxedUint32 once it is fully supported/optimized. | 2716 // TODO(zerny): Use kUnboxedUint32 once it is fully supported/optimized. |
2752 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) | 2717 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) |
2753 if (!instr->can_pack_into_smi()) | 2718 if (!instr->can_pack_into_smi()) |
2754 instr->set_representation(kUnboxedMint); | 2719 instr->set_representation(kUnboxedMint); |
2755 #endif | 2720 #endif |
2756 } | 2721 } |
2757 | 2722 |
2758 | 2723 |
2759 bool AotOptimizer::TryInlineInstanceSetter(InstanceCallInstr* instr, | 2724 bool AotOptimizer::TryInlineInstanceSetter(InstanceCallInstr* instr, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2807 | 2772 |
2808 // Discard the environment from the original instruction because the store | 2773 // Discard the environment from the original instruction because the store |
2809 // can't deoptimize. | 2774 // can't deoptimize. |
2810 instr->RemoveEnvironment(); | 2775 instr->RemoveEnvironment(); |
2811 ReplaceCall(instr, store); | 2776 ReplaceCall(instr, store); |
2812 return true; | 2777 return true; |
2813 } | 2778 } |
2814 | 2779 |
2815 | 2780 |
2816 } // namespace dart | 2781 } // namespace dart |
OLD | NEW |