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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 AllocateIncomingParametersRecursive(deoptimization_env_, &stack_height); | 69 AllocateIncomingParametersRecursive(deoptimization_env_, &stack_height); |
| 70 | 70 |
| 71 const Function& function = compiler->parsed_function().function(); | 71 const Function& function = compiler->parsed_function().function(); |
| 72 // For functions with optional arguments, all incoming arguments are copied | 72 // For functions with optional arguments, all incoming arguments are copied |
| 73 // to spill slots. The deoptimization environment does not track them. | 73 // to spill slots. The deoptimization environment does not track them. |
| 74 const intptr_t incoming_arg_count = | 74 const intptr_t incoming_arg_count = |
| 75 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); | 75 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters(); |
| 76 DeoptInfoBuilder builder(compiler->object_table(), incoming_arg_count); | 76 DeoptInfoBuilder builder(compiler->object_table(), incoming_arg_count); |
| 77 | 77 |
| 78 intptr_t slot_ix = 0; | 78 intptr_t slot_ix = 0; |
| 79 Environment* env = deoptimization_env_; | 79 Environment* inner = deoptimization_env_; |
| 80 while (env != NULL) { | |
| 81 const Function& function = env->function(); | |
| 82 const intptr_t fixed_parameter_count = env->fixed_parameter_count(); | |
| 83 | 80 |
| 84 if (slot_ix == 0) { | 81 // For the innermost environment, call the virtual return builder. |
| 85 // For the innermost environment call the virtual return builder. | 82 BuildReturnAddress(&builder, inner->function(), slot_ix++); |
| 86 BuildReturnAddress(&builder, function, slot_ix++); | 83 |
| 87 } else { | 84 // For the innermost environment, set outgoing arguments and the locals. |
| 88 // For any outer environment the deopt id is that of the call instruction | 85 for (intptr_t i = inner->Length() - 1; |
| 89 // which is recorded in the outer environment. | 86 i >= inner->fixed_parameter_count(); |
| 90 builder.AddReturnAddressAfter(function, env->deopt_id(), slot_ix++); | 87 i--) { |
| 88 builder.AddCopy(inner->LocationAt(i), *inner->ValueAt(i), slot_ix++); | |
| 89 } | |
| 90 | |
| 91 // PC marker and caller FP. | |
| 92 builder.AddPcMarker(inner->function(), slot_ix++); | |
| 93 builder.AddCallerFp(slot_ix++); | |
| 94 | |
| 95 while (inner->outer() != NULL) { | |
| 96 // Write the frame for an outer environment. | |
| 97 const Environment* current = inner->outer(); | |
| 98 | |
| 99 // For any outer environment the deopt id is that of the call instruction | |
| 100 // which is recorded in the outer environment. | |
| 101 builder.AddReturnAddressAfter(current->function(), | |
| 102 current->deopt_id(), | |
| 103 slot_ix++); | |
| 104 | |
| 105 // Set incoming arguments from the inner frame. | |
| 106 for (intptr_t i = inner->fixed_parameter_count() - 1; i >= 0; i--) { | |
| 107 builder.AddCopy(inner->LocationAt(i), *inner->ValueAt(i), slot_ix++); | |
| 91 } | 108 } |
| 92 | 109 |
| 93 for (intptr_t i = env->Length() - 1; i >= fixed_parameter_count; i--) { | 110 // Set the locals, not including the outgoing arguments. |
| 94 builder.AddCopy(env->LocationAt(i), *env->ValueAt(i), slot_ix++); | 111 for (intptr_t i = current->Length() - inner->fixed_parameter_count() - 1; |
| 112 i >= current->fixed_parameter_count(); | |
| 113 i--) { | |
| 114 builder.AddCopy(current->LocationAt(i), *current->ValueAt(i), slot_ix++); | |
| 95 } | 115 } |
| 96 | 116 |
| 97 // PC marker and caller FP. | 117 // PC marker and caller FP. |
| 98 builder.AddPcMarker(function, slot_ix++); | 118 builder.AddPcMarker(current->function(), slot_ix++); |
| 99 builder.AddCallerFp(slot_ix++); | 119 builder.AddCallerFp(slot_ix++); |
| 100 | 120 |
| 101 // On the outermost environment set caller PC and incoming arguments. | 121 // Iterate on the outer environment. |
| 102 if (env->outer() == NULL) { | 122 inner = inner->outer(); |
| 103 builder.AddCallerPc(slot_ix++); | 123 } |
| 104 for (intptr_t i = fixed_parameter_count - 1; i >= 0; i--) { | 124 ASSERT(inner != NULL); // The inner pointer is not the outermost environment. |
|
Vyacheslav Egorov (Google)
2012/09/21 14:38:30
actually at this point is has to be the outermost
zerny-google
2012/09/21 14:55:47
Typo. That should have been "is now the outermost"
| |
| 105 builder.AddCopy(env->LocationAt(i), *env->ValueAt(i), slot_ix++); | |
| 106 } | |
| 107 } | |
| 108 | 125 |
| 109 // Iterate on the outer environment. | 126 // For the outermost environment, set caller PC. |
| 110 env = env->outer(); | 127 builder.AddCallerPc(slot_ix++); |
| 128 | |
| 129 // For the outermost environment, set the incoming arguments. | |
| 130 for (intptr_t i = inner->fixed_parameter_count() - 1; i >= 0; i--) { | |
| 131 builder.AddCopy(inner->LocationAt(i), *inner->ValueAt(i), slot_ix++); | |
| 111 } | 132 } |
| 112 | 133 |
| 113 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder.CreateDeoptInfo()); | 134 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder.CreateDeoptInfo()); |
| 114 return deopt_info.raw(); | 135 return deopt_info.raw(); |
| 115 } | 136 } |
| 116 | 137 |
| 117 | 138 |
| 118 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, | 139 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, |
| 119 const FlowGraph& flow_graph, | 140 const FlowGraph& flow_graph, |
| 120 bool is_optimizing, | 141 bool is_optimizing, |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 876 case ABOVE: return unsigned_left > unsigned_right; | 897 case ABOVE: return unsigned_left > unsigned_right; |
| 877 case ABOVE_EQUAL: return unsigned_left >= unsigned_right; | 898 case ABOVE_EQUAL: return unsigned_left >= unsigned_right; |
| 878 default: | 899 default: |
| 879 UNIMPLEMENTED(); | 900 UNIMPLEMENTED(); |
| 880 return false; | 901 return false; |
| 881 } | 902 } |
| 882 } | 903 } |
| 883 | 904 |
| 884 | 905 |
| 885 } // namespace dart | 906 } // namespace dart |
| OLD | NEW |