Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 |
| 41 void CompilerDeoptInfoWithStub::BuildReturnAddress(DeoptInfoBuilder* builder, | 41 void CompilerDeoptInfoWithStub::BuildReturnAddress(DeoptInfoBuilder* builder, |
| 42 const Function& function, | 42 const Function& function, |
| 43 intptr_t slot_ix) { | 43 intptr_t slot_ix) { |
| 44 builder->AddReturnAddressBefore(function, deopt_id(), slot_ix); | 44 builder->AddReturnAddressBefore(function, deopt_id(), slot_ix); |
| 45 } | 45 } |
| 46 | 46 |
| 47 | 47 |
| 48 // Assign locations to outgoing arguments, i.e., values pushed above spill slots | |
| 49 // with PushArgument. Recursively allocates from outer most to inner most | |
|
Kevin Millikin (Google)
2012/09/18 11:01:55
"outer most" ==> "outermost", "inner most" ==> "in
zerny-google
2012/09/18 11:53:07
Done.
| |
| 50 // environment. | |
| 51 void CompilerDeoptInfo::AllocateIncommingParametersRecusive( | |
| 52 Environment* env, | |
| 53 intptr_t* stack_height) { | |
| 54 if (env == NULL) return; | |
| 55 AllocateIncommingParametersRecusive(env->outer(), stack_height); | |
| 56 for (Environment::ShallowIterator it(env); !it.Done(); it.Advance()) { | |
| 57 if (it.CurrentLocation().IsInvalid()) { | |
| 58 ASSERT(it.CurrentValue()->definition()->IsPushArgument()); | |
| 59 it.SetCurrentLocation(Location::StackSlot((*stack_height)++)); | |
| 60 } | |
| 61 } | |
| 62 } | |
| 63 | |
| 64 | |
| 48 RawDeoptInfo* CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler) { | 65 RawDeoptInfo* CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler) { |
| 49 if (deoptimization_env_ == NULL) return DeoptInfo::null(); | 66 if (deoptimization_env_ == NULL) return DeoptInfo::null(); |
| 67 | |
| 68 intptr_t stack_height = compiler->StackSize(); | |
| 69 AllocateIncommingParametersRecusive(deoptimization_env_, &stack_height); | |
| 70 | |
| 50 const Function& function = compiler->parsed_function().function(); | 71 const Function& function = compiler->parsed_function().function(); |
| 51 // For functions with optional arguments, all incoming are copied to local | 72 const intptr_t num_incoming_args = |
| 52 // area below FP, deoptimization environment does not track them. | |
| 53 const intptr_t num_args = | |
| 54 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); | 73 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); |
| 55 const intptr_t fixed_parameter_count = | 74 DeoptInfoBuilder builder(compiler->object_table(), num_incoming_args); |
| 56 deoptimization_env_->fixed_parameter_count(); | |
| 57 DeoptInfoBuilder builder(compiler->object_table(), num_args); | |
| 58 | 75 |
| 59 intptr_t slot_ix = 0; | 76 intptr_t slot_ix = 0; |
| 60 BuildReturnAddress(&builder, function, slot_ix++); | 77 Environment* env = deoptimization_env_; |
| 78 while (env != NULL) { | |
| 79 const Function& function = env->function(); | |
| 61 | 80 |
| 62 // Assign locations to values pushed above spill slots with PushArgument. | 81 // For functions with optional arguments, all incoming are copied to local |
|
Kevin Millikin (Google)
2012/09/18 11:01:55
Hmm. I would say they're "above" the frame pointe
zerny-google
2012/09/18 11:53:07
Also, the this comment is for num_incoming_args (r
| |
| 63 intptr_t height = compiler->StackSize(); | 82 // area below FP, deoptimization environment does not track them. |
| 64 for (intptr_t i = 0; i < deoptimization_env_->Length(); i++) { | 83 const intptr_t fixed_parameter_count = env->fixed_parameter_count(); |
| 65 if (deoptimization_env_->LocationAt(i).IsInvalid()) { | 84 |
| 66 ASSERT(deoptimization_env_->ValueAt(i)->definition()->IsPushArgument()); | 85 if (slot_ix == 0) { |
| 67 *deoptimization_env_->LocationSlotAt(i) = Location::StackSlot(height++); | 86 // For the inner-most environment call the virutal return builder. |
|
Kevin Millikin (Google)
2012/09/18 11:01:55
"virutal" ==> "virtual".
zerny-google
2012/09/18 11:53:07
Done.
| |
| 87 BuildReturnAddress(&builder, function, slot_ix++); | |
| 88 } else { | |
| 89 // For any outer environment the deopt id is that of the call instruction | |
| 90 // which is recorded in the outer environment. | |
| 91 builder.AddReturnAddressAfter(function, env->deopt_id(), slot_ix++); | |
| 68 } | 92 } |
| 69 } | |
| 70 | 93 |
| 71 for (intptr_t i = deoptimization_env_->Length() - 1; | 94 for (intptr_t i = env->Length() - 1; i >= fixed_parameter_count; i--) { |
| 72 i >= fixed_parameter_count; | 95 builder.AddCopy(env->LocationAt(i), *env->ValueAt(i), slot_ix++); |
| 73 i--) { | 96 } |
| 74 builder.AddCopy(deoptimization_env_->LocationAt(i), | |
| 75 *deoptimization_env_->ValueAt(i), | |
| 76 slot_ix++); | |
| 77 } | |
| 78 | 97 |
| 79 // PC marker, caller-fp, caller-pc. | 98 // PC marker and caller FP. |
| 80 builder.AddPcMarker(function, slot_ix++); | 99 builder.AddPcMarker(function, slot_ix++); |
| 81 builder.AddCallerFp(slot_ix++); | 100 builder.AddCallerFp(slot_ix++); |
| 82 builder.AddCallerPc(slot_ix++); | 101 |
| 83 // Incoming arguments. | 102 // On the outer-most environment set caller PC and incoming arguments. |
| 84 for (intptr_t i = fixed_parameter_count - 1; i >= 0; i--) { | 103 if (env->outer() == NULL) { |
| 85 builder.AddCopy(deoptimization_env_->LocationAt(i), | 104 builder.AddCallerPc(slot_ix++); |
| 86 *deoptimization_env_->ValueAt(i), | 105 for (intptr_t i = fixed_parameter_count - 1; i >= 0; i--) { |
| 87 slot_ix++); | 106 builder.AddCopy(env->LocationAt(i), *env->ValueAt(i), slot_ix++); |
| 107 } | |
| 108 } | |
| 109 | |
| 110 // Iterate on the outer environment. | |
| 111 env = env->outer(); | |
| 88 } | 112 } |
| 89 | 113 |
| 90 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder.CreateDeoptInfo()); | 114 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder.CreateDeoptInfo()); |
| 91 return deopt_info.raw(); | 115 return deopt_info.raw(); |
| 92 } | 116 } |
| 93 | 117 |
| 94 | 118 |
| 95 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, | 119 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, |
| 96 const FlowGraph& flow_graph, | 120 const FlowGraph& flow_graph, |
| 97 bool is_optimizing, | 121 bool is_optimizing, |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( | 359 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( |
| 336 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); | 360 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); |
| 337 code.set_exception_handlers(handlers); | 361 code.set_exception_handlers(handlers); |
| 338 } | 362 } |
| 339 | 363 |
| 340 | 364 |
| 341 void FlowGraphCompiler::FinalizePcDescriptors(const Code& code) { | 365 void FlowGraphCompiler::FinalizePcDescriptors(const Code& code) { |
| 342 ASSERT(pc_descriptors_list_ != NULL); | 366 ASSERT(pc_descriptors_list_ != NULL); |
| 343 const PcDescriptors& descriptors = PcDescriptors::Handle( | 367 const PcDescriptors& descriptors = PcDescriptors::Handle( |
| 344 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint())); | 368 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint())); |
| 345 descriptors.Verify(parsed_function_.function().is_optimizable()); | 369 if (!is_optimizing_) descriptors.Verify(parsed_function_.function()); |
| 346 code.set_pc_descriptors(descriptors); | 370 code.set_pc_descriptors(descriptors); |
| 347 } | 371 } |
| 348 | 372 |
| 349 | 373 |
| 350 void FlowGraphCompiler::FinalizeDeoptInfo(const Code& code) { | 374 void FlowGraphCompiler::FinalizeDeoptInfo(const Code& code) { |
| 351 const Array& array = | 375 const Array& array = |
| 352 Array::Handle(Array::New(deopt_infos_.length(), Heap::kOld)); | 376 Array::Handle(Array::New(deopt_infos_.length(), Heap::kOld)); |
| 353 DeoptInfo& info = DeoptInfo::Handle(); | 377 DeoptInfo& info = DeoptInfo::Handle(); |
| 354 for (intptr_t i = 0; i < deopt_infos_.length(); i++) { | 378 for (intptr_t i = 0; i < deopt_infos_.length(); i++) { |
| 355 info = deopt_infos_[i]->CreateDeoptInfo(this); | 379 info = deopt_infos_[i]->CreateDeoptInfo(this); |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 853 case ABOVE: return unsigned_left > unsigned_right; | 877 case ABOVE: return unsigned_left > unsigned_right; |
| 854 case ABOVE_EQUAL: return unsigned_left >= unsigned_right; | 878 case ABOVE_EQUAL: return unsigned_left >= unsigned_right; |
| 855 default: | 879 default: |
| 856 UNIMPLEMENTED(); | 880 UNIMPLEMENTED(); |
| 857 return false; | 881 return false; |
| 858 } | 882 } |
| 859 } | 883 } |
| 860 | 884 |
| 861 | 885 |
| 862 } // namespace dart | 886 } // namespace dart |
| OLD | NEW |