| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // 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 |
| 36 // with PushArgument. Recursively allocates from outermost to innermost | 36 // with PushArgument. Recursively allocates from outermost to innermost |
| 37 // environment. | 37 // environment. |
| 38 void CompilerDeoptInfo::AllocateIncomingParametersRecursive( | 38 void CompilerDeoptInfo::AllocateIncomingParametersRecursive( |
| 39 Environment* env, | 39 Environment* env, |
| 40 intptr_t* stack_height) { | 40 intptr_t* stack_height) { |
| 41 if (env == NULL) return; | 41 if (env == NULL) return; |
| 42 AllocateIncomingParametersRecursive(env->outer(), stack_height); | 42 AllocateIncomingParametersRecursive(env->outer(), stack_height); |
| 43 for (Environment::ShallowIterator it(env); !it.Done(); it.Advance()) { | 43 for (Environment::ShallowIterator it(env); !it.Done(); it.Advance()) { |
| 44 if (it.CurrentLocation().IsInvalid() && |
| 45 it.CurrentValue()->definition()->IsPushArgument()) { |
| 46 it.SetCurrentLocation(Location::StackSlot((*stack_height)++)); |
| 47 } |
| 48 } |
| 49 } |
| 50 |
| 51 |
| 52 void CompilerDeoptInfo::EmitMaterializations(Environment* env, |
| 53 DeoptInfoBuilder* builder) { |
| 54 for (Environment::DeepIterator it(env); !it.Done(); it.Advance()) { |
| 44 if (it.CurrentLocation().IsInvalid()) { | 55 if (it.CurrentLocation().IsInvalid()) { |
| 45 ASSERT(it.CurrentValue()->definition()->IsPushArgument()); | 56 MaterializeObjectInstr* mat = |
| 46 it.SetCurrentLocation(Location::StackSlot((*stack_height)++)); | 57 it.CurrentValue()->definition()->AsMaterializeObject(); |
| 58 ASSERT(mat != NULL); |
| 59 builder->AddMaterialization(mat); |
| 47 } | 60 } |
| 48 } | 61 } |
| 49 } | 62 } |
| 50 | 63 |
| 51 | 64 |
| 52 RawDeoptInfo* CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler, | 65 RawDeoptInfo* CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler, |
| 53 DeoptInfoBuilder* builder) { | 66 DeoptInfoBuilder* builder) { |
| 54 if (deoptimization_env_ == NULL) return DeoptInfo::null(); | 67 if (deoptimization_env_ == NULL) return DeoptInfo::null(); |
| 55 | 68 |
| 56 intptr_t stack_height = compiler->StackSize(); | 69 intptr_t stack_height = compiler->StackSize(); |
| 57 AllocateIncomingParametersRecursive(deoptimization_env_, &stack_height); | 70 AllocateIncomingParametersRecursive(deoptimization_env_, &stack_height); |
| 58 | 71 |
| 59 intptr_t slot_ix = 0; | 72 intptr_t slot_ix = 0; |
| 60 Environment* current = deoptimization_env_; | 73 Environment* current = deoptimization_env_; |
| 61 | 74 |
| 75 // Emit all kMaterializeObject instructions describing objects to be |
| 76 // materialized on the deoptimization as a prefix to the deoptimization info. |
| 77 EmitMaterializations(deoptimization_env_, builder); |
| 78 |
| 79 // The real frame starts here. |
| 80 builder->MarkFrameStart(); |
| 62 builder->AddReturnAddress(current->function(), | 81 builder->AddReturnAddress(current->function(), |
| 63 deopt_id(), | 82 deopt_id(), |
| 64 slot_ix++); | 83 slot_ix++); |
| 65 | 84 |
| 85 // Emit all values that are needed for materialization as a part of the |
| 86 // expression stack for the bottom-most frame. This guarantees that GC |
| 87 // will be able to find them during materialization. |
| 88 slot_ix = builder->EmitMaterializationArguments(); |
| 89 |
| 66 // For the innermost environment, set outgoing arguments and the locals. | 90 // For the innermost environment, set outgoing arguments and the locals. |
| 67 for (intptr_t i = current->Length() - 1; | 91 for (intptr_t i = current->Length() - 1; |
| 68 i >= current->fixed_parameter_count(); | 92 i >= current->fixed_parameter_count(); |
| 69 i--) { | 93 i--) { |
| 70 builder->AddCopy(current->ValueAt(i), current->LocationAt(i), slot_ix++); | 94 builder->AddCopy(current->ValueAt(i), current->LocationAt(i), slot_ix++); |
| 71 } | 95 } |
| 72 | 96 |
| 73 // PC marker and caller FP. | 97 // PC marker and caller FP. |
| 74 builder->AddPcMarker(current->function(), slot_ix++); | 98 builder->AddPcMarker(current->function(), slot_ix++); |
| 75 builder->AddCallerFp(slot_ix++); | 99 builder->AddCallerFp(slot_ix++); |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 | 1165 |
| 1142 for (int i = 0; i < len; i++) { | 1166 for (int i = 0; i < len; i++) { |
| 1143 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), | 1167 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), |
| 1144 &Function::ZoneHandle(ic_data.GetTargetAt(i)), | 1168 &Function::ZoneHandle(ic_data.GetTargetAt(i)), |
| 1145 ic_data.GetCountAt(i))); | 1169 ic_data.GetCountAt(i))); |
| 1146 } | 1170 } |
| 1147 sorted->Sort(HighestCountFirst); | 1171 sorted->Sort(HighestCountFirst); |
| 1148 } | 1172 } |
| 1149 | 1173 |
| 1150 } // namespace dart | 1174 } // namespace dart |
| OLD | NEW |