| 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/globals.h" // Needed here to get TARGET_ARCH_XXX. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. |
| 6 | 6 |
| 7 #include "vm/flow_graph_compiler.h" | 7 #include "vm/flow_graph_compiler.h" |
| 8 | 8 |
| 9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); | 25 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); |
| 26 DECLARE_FLAG(bool, code_comments); | 26 DECLARE_FLAG(bool, code_comments); |
| 27 DECLARE_FLAG(bool, enable_type_checks); | 27 DECLARE_FLAG(bool, enable_type_checks); |
| 28 DECLARE_FLAG(bool, intrinsify); | 28 DECLARE_FLAG(bool, intrinsify); |
| 29 DECLARE_FLAG(bool, propagate_ic_data); | 29 DECLARE_FLAG(bool, propagate_ic_data); |
| 30 DECLARE_FLAG(bool, report_usage_count); | 30 DECLARE_FLAG(bool, report_usage_count); |
| 31 DECLARE_FLAG(int, optimization_counter_threshold); | 31 DECLARE_FLAG(int, optimization_counter_threshold); |
| 32 DECLARE_FLAG(bool, use_cha); | 32 DECLARE_FLAG(bool, use_cha); |
| 33 | 33 |
| 34 void CompilerDeoptInfo::BuildReturnAddress(DeoptInfoBuilder* builder, | |
| 35 const Function& function, | |
| 36 intptr_t slot_ix) { | |
| 37 builder->AddReturnAddressAfter(function, deopt_id(), slot_ix); | |
| 38 } | |
| 39 | |
| 40 | |
| 41 void CompilerDeoptInfoWithStub::BuildReturnAddress(DeoptInfoBuilder* builder, | |
| 42 const Function& function, | |
| 43 intptr_t slot_ix) { | |
| 44 builder->AddReturnAddressBefore(function, deopt_id(), slot_ix); | |
| 45 } | |
| 46 | |
| 47 | 34 |
| 48 // Assign locations to incoming arguments, i.e., values pushed above spill slots | 35 // Assign locations to incoming arguments, i.e., values pushed above spill slots |
| 49 // with PushArgument. Recursively allocates from outermost to innermost | 36 // with PushArgument. Recursively allocates from outermost to innermost |
| 50 // environment. | 37 // environment. |
| 51 void CompilerDeoptInfo::AllocateIncomingParametersRecursive( | 38 void CompilerDeoptInfo::AllocateIncomingParametersRecursive( |
| 52 Environment* env, | 39 Environment* env, |
| 53 intptr_t* stack_height) { | 40 intptr_t* stack_height) { |
| 54 if (env == NULL) return; | 41 if (env == NULL) return; |
| 55 AllocateIncomingParametersRecursive(env->outer(), stack_height); | 42 AllocateIncomingParametersRecursive(env->outer(), stack_height); |
| 56 for (Environment::ShallowIterator it(env); !it.Done(); it.Advance()) { | 43 for (Environment::ShallowIterator it(env); !it.Done(); it.Advance()) { |
| 57 if (it.CurrentLocation().IsInvalid()) { | 44 if (it.CurrentLocation().IsInvalid()) { |
| 58 ASSERT(it.CurrentValue()->definition()->IsPushArgument()); | 45 ASSERT(it.CurrentValue()->definition()->IsPushArgument()); |
| 59 it.SetCurrentLocation(Location::StackSlot((*stack_height)++)); | 46 it.SetCurrentLocation(Location::StackSlot((*stack_height)++)); |
| 60 } | 47 } |
| 61 } | 48 } |
| 62 } | 49 } |
| 63 | 50 |
| 64 | 51 |
| 65 RawDeoptInfo* CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler, | 52 RawDeoptInfo* CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler, |
| 66 DeoptInfoBuilder* builder) { | 53 DeoptInfoBuilder* builder) { |
| 67 if (deoptimization_env_ == NULL) return DeoptInfo::null(); | 54 if (deoptimization_env_ == NULL) return DeoptInfo::null(); |
| 68 | 55 |
| 69 intptr_t stack_height = compiler->StackSize(); | 56 intptr_t stack_height = compiler->StackSize(); |
| 70 AllocateIncomingParametersRecursive(deoptimization_env_, &stack_height); | 57 AllocateIncomingParametersRecursive(deoptimization_env_, &stack_height); |
| 71 | 58 |
| 72 intptr_t slot_ix = 0; | 59 intptr_t slot_ix = 0; |
| 73 Environment* current = deoptimization_env_; | 60 Environment* current = deoptimization_env_; |
| 74 | 61 |
| 75 // For the innermost environment, call the virtual return builder. | 62 builder->AddReturnAddress(current->function(), |
| 76 BuildReturnAddress(builder, current->function(), slot_ix++); | 63 deopt_id(), |
| 64 slot_ix++); |
| 77 | 65 |
| 78 // For the innermost environment, set outgoing arguments and the locals. | 66 // For the innermost environment, set outgoing arguments and the locals. |
| 79 for (intptr_t i = current->Length() - 1; | 67 for (intptr_t i = current->Length() - 1; |
| 80 i >= current->fixed_parameter_count(); | 68 i >= current->fixed_parameter_count(); |
| 81 i--) { | 69 i--) { |
| 82 builder->AddCopy(current->LocationAt(i), slot_ix++); | 70 builder->AddCopy(current->LocationAt(i), slot_ix++); |
| 83 } | 71 } |
| 84 | 72 |
| 85 // PC marker and caller FP. | 73 // PC marker and caller FP. |
| 86 builder->AddPcMarker(current->function(), slot_ix++); | 74 builder->AddPcMarker(current->function(), slot_ix++); |
| 87 builder->AddCallerFp(slot_ix++); | 75 builder->AddCallerFp(slot_ix++); |
| 88 | 76 |
| 89 Environment* previous = current; | 77 Environment* previous = current; |
| 90 current = current->outer(); | 78 current = current->outer(); |
| 91 while (current != NULL) { | 79 while (current != NULL) { |
| 92 // For any outer environment the deopt id is that of the call instruction | 80 // For any outer environment the deopt id is that of the call instruction |
| 93 // which is recorded in the outer environment. | 81 // which is recorded in the outer environment. |
| 94 builder->AddReturnAddressAfter(current->function(), | 82 builder->AddReturnAddress(current->function(), |
| 95 current->deopt_id(), | 83 Isolate::ToDeoptAfter(current->deopt_id()), |
| 96 slot_ix++); | 84 slot_ix++); |
| 97 | 85 |
| 98 // The values of outgoing arguments can be changed from the inlined call so | 86 // The values of outgoing arguments can be changed from the inlined call so |
| 99 // we must read them from the previous environment. | 87 // we must read them from the previous environment. |
| 100 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { | 88 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { |
| 101 builder->AddCopy(previous->LocationAt(i), slot_ix++); | 89 builder->AddCopy(previous->LocationAt(i), slot_ix++); |
| 102 } | 90 } |
| 103 | 91 |
| 104 // Set the locals, note that outgoing arguments are not in the environment. | 92 // Set the locals, note that outgoing arguments are not in the environment. |
| 105 for (intptr_t i = current->Length() - 1; | 93 for (intptr_t i = current->Length() - 1; |
| 106 i >= current->fixed_parameter_count(); | 94 i >= current->fixed_parameter_count(); |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 if (i != largest_ix) { | 1024 if (i != largest_ix) { |
| 1037 // Swap. | 1025 // Swap. |
| 1038 CidTarget temp = (*sorted)[i]; | 1026 CidTarget temp = (*sorted)[i]; |
| 1039 (*sorted)[i] = (*sorted)[largest_ix]; | 1027 (*sorted)[i] = (*sorted)[largest_ix]; |
| 1040 (*sorted)[largest_ix] = temp; | 1028 (*sorted)[largest_ix] = temp; |
| 1041 } | 1029 } |
| 1042 } | 1030 } |
| 1043 } | 1031 } |
| 1044 | 1032 |
| 1045 } // namespace dart | 1033 } // namespace dart |
| OLD | NEW |