| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 intptr_t slot_ix = 0; | 72 intptr_t slot_ix = 0; |
| 73 Environment* current = deoptimization_env_; | 73 Environment* current = deoptimization_env_; |
| 74 | 74 |
| 75 // For the innermost environment, call the virtual return builder. | 75 // For the innermost environment, call the virtual return builder. |
| 76 BuildReturnAddress(builder, current->function(), slot_ix++); | 76 BuildReturnAddress(builder, current->function(), slot_ix++); |
| 77 | 77 |
| 78 // For the innermost environment, set outgoing arguments and the locals. | 78 // For the innermost environment, set outgoing arguments and the locals. |
| 79 for (intptr_t i = current->Length() - 1; | 79 for (intptr_t i = current->Length() - 1; |
| 80 i >= current->fixed_parameter_count(); | 80 i >= current->fixed_parameter_count(); |
| 81 i--) { | 81 i--) { |
| 82 builder->AddCopy(current->LocationAt(i), *current->ValueAt(i), slot_ix++); | 82 builder->AddCopy(current->LocationAt(i), slot_ix++); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // PC marker and caller FP. | 85 // PC marker and caller FP. |
| 86 builder->AddPcMarker(current->function(), slot_ix++); | 86 builder->AddPcMarker(current->function(), slot_ix++); |
| 87 builder->AddCallerFp(slot_ix++); | 87 builder->AddCallerFp(slot_ix++); |
| 88 | 88 |
| 89 Environment* previous = current; | 89 Environment* previous = current; |
| 90 current = current->outer(); | 90 current = current->outer(); |
| 91 while (current != NULL) { | 91 while (current != NULL) { |
| 92 // For any outer environment the deopt id is that of the call instruction | 92 // For any outer environment the deopt id is that of the call instruction |
| 93 // which is recorded in the outer environment. | 93 // which is recorded in the outer environment. |
| 94 builder->AddReturnAddressAfter(current->function(), | 94 builder->AddReturnAddressAfter(current->function(), |
| 95 current->deopt_id(), | 95 current->deopt_id(), |
| 96 slot_ix++); | 96 slot_ix++); |
| 97 | 97 |
| 98 // The values of outgoing arguments can be changed from the inlined call so | 98 // The values of outgoing arguments can be changed from the inlined call so |
| 99 // we must read them from the previous environment. | 99 // we must read them from the previous environment. |
| 100 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { | 100 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { |
| 101 builder->AddCopy(previous->LocationAt(i), *previous->ValueAt(i), | 101 builder->AddCopy(previous->LocationAt(i), slot_ix++); |
| 102 slot_ix++); | |
| 103 } | 102 } |
| 104 | 103 |
| 105 // Set the locals, note that outgoing arguments are not in the environment. | 104 // Set the locals, note that outgoing arguments are not in the environment. |
| 106 for (intptr_t i = current->Length() - 1; | 105 for (intptr_t i = current->Length() - 1; |
| 107 i >= current->fixed_parameter_count(); | 106 i >= current->fixed_parameter_count(); |
| 108 i--) { | 107 i--) { |
| 109 builder->AddCopy(current->LocationAt(i), *current->ValueAt(i), slot_ix++); | 108 builder->AddCopy(current->LocationAt(i), slot_ix++); |
| 110 } | 109 } |
| 111 | 110 |
| 112 // PC marker and caller FP. | 111 // PC marker and caller FP. |
| 113 builder->AddPcMarker(current->function(), slot_ix++); | 112 builder->AddPcMarker(current->function(), slot_ix++); |
| 114 builder->AddCallerFp(slot_ix++); | 113 builder->AddCallerFp(slot_ix++); |
| 115 | 114 |
| 116 // Iterate on the outer environment. | 115 // Iterate on the outer environment. |
| 117 previous = current; | 116 previous = current; |
| 118 current = current->outer(); | 117 current = current->outer(); |
| 119 } | 118 } |
| 120 // The previous pointer is now the outermost environment. | 119 // The previous pointer is now the outermost environment. |
| 121 ASSERT(previous != NULL); | 120 ASSERT(previous != NULL); |
| 122 | 121 |
| 123 // For the outermost environment, set caller PC. | 122 // For the outermost environment, set caller PC. |
| 124 builder->AddCallerPc(slot_ix++); | 123 builder->AddCallerPc(slot_ix++); |
| 125 | 124 |
| 126 // For the outermost environment, set the incoming arguments. | 125 // For the outermost environment, set the incoming arguments. |
| 127 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { | 126 for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) { |
| 128 builder->AddCopy(previous->LocationAt(i), *previous->ValueAt(i), slot_ix++); | 127 builder->AddCopy(previous->LocationAt(i), slot_ix++); |
| 129 } | 128 } |
| 130 | 129 |
| 131 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder->CreateDeoptInfo()); | 130 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder->CreateDeoptInfo()); |
| 132 return deopt_info.raw(); | 131 return deopt_info.raw(); |
| 133 } | 132 } |
| 134 | 133 |
| 135 | 134 |
| 136 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, | 135 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, |
| 137 const FlowGraph& flow_graph, | 136 const FlowGraph& flow_graph, |
| 138 bool is_optimizing) | 137 bool is_optimizing) |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 if (i != largest_ix) { | 1076 if (i != largest_ix) { |
| 1078 // Swap. | 1077 // Swap. |
| 1079 CidTarget temp = (*sorted)[i]; | 1078 CidTarget temp = (*sorted)[i]; |
| 1080 (*sorted)[i] = (*sorted)[largest_ix]; | 1079 (*sorted)[i] = (*sorted)[largest_ix]; |
| 1081 (*sorted)[largest_ix] = temp; | 1080 (*sorted)[largest_ix] = temp; |
| 1082 } | 1081 } |
| 1083 } | 1082 } |
| 1084 } | 1083 } |
| 1085 | 1084 |
| 1086 } // namespace dart | 1085 } // namespace dart |
| OLD | NEW |