| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 const Function& function = parsed_function().function(); | 1135 const Function& function = parsed_function().function(); |
| 1136 | 1136 |
| 1137 const int num_fixed_params = function.num_fixed_parameters(); | 1137 const int num_fixed_params = function.num_fixed_parameters(); |
| 1138 const int num_copied_params = parsed_function().num_copied_params(); | 1138 const int num_copied_params = parsed_function().num_copied_params(); |
| 1139 const int num_locals = parsed_function().num_stack_locals(); | 1139 const int num_locals = parsed_function().num_stack_locals(); |
| 1140 | 1140 |
| 1141 // We check the number of passed arguments when we have to copy them due to | 1141 // We check the number of passed arguments when we have to copy them due to |
| 1142 // the presence of optional parameters. | 1142 // the presence of optional parameters. |
| 1143 // No such checking code is generated if only fixed parameters are declared, | 1143 // No such checking code is generated if only fixed parameters are declared, |
| 1144 // unless we are in debug mode or unless we are compiling a closure. | 1144 // unless we are in debug mode or unless we are compiling a closure. |
| 1145 LocalVariable* saved_args_desc_var = | |
| 1146 parsed_function().GetSavedArgumentsDescriptorVar(); | |
| 1147 if (num_copied_params == 0) { | 1145 if (num_copied_params == 0) { |
| 1148 #ifdef DEBUG | 1146 #ifdef DEBUG |
| 1149 ASSERT(!parsed_function().function().HasOptionalParameters()); | 1147 ASSERT(!parsed_function().function().HasOptionalParameters()); |
| 1150 const bool check_arguments = !flow_graph().IsCompiledForOsr(); | 1148 const bool check_arguments = !flow_graph().IsCompiledForOsr(); |
| 1151 #else | 1149 #else |
| 1152 const bool check_arguments = | 1150 const bool check_arguments = |
| 1153 (function.IsClosureFunction() || function.IsNoSuchMethodDispatcher()) && | 1151 (function.IsClosureFunction() || function.IsNoSuchMethodDispatcher()) && |
| 1154 !flow_graph().IsCompiledForOsr(); | 1152 !flow_graph().IsCompiledForOsr(); |
| 1155 #endif | 1153 #endif |
| 1156 if (check_arguments) { | 1154 if (check_arguments) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 0); // No registers. | 1202 0); // No registers. |
| 1205 } | 1203 } |
| 1206 // The noSuchMethod call may return. | 1204 // The noSuchMethod call may return. |
| 1207 __ LeaveFrame(); | 1205 __ LeaveFrame(); |
| 1208 __ ret(); | 1206 __ ret(); |
| 1209 } else { | 1207 } else { |
| 1210 __ Stop("Wrong number of arguments"); | 1208 __ Stop("Wrong number of arguments"); |
| 1211 } | 1209 } |
| 1212 __ Bind(&correct_num_arguments); | 1210 __ Bind(&correct_num_arguments); |
| 1213 } | 1211 } |
| 1214 // The arguments descriptor is never saved in the absence of optional | |
| 1215 // parameters, since any argument definition test would always yield true. | |
| 1216 ASSERT(saved_args_desc_var == NULL); | |
| 1217 } else if (!flow_graph().IsCompiledForOsr()) { | 1212 } else if (!flow_graph().IsCompiledForOsr()) { |
| 1218 if (saved_args_desc_var != NULL) { | |
| 1219 __ Comment("Save arguments descriptor"); | |
| 1220 const Register kArgumentsDescriptorReg = EDX; | |
| 1221 // The saved_args_desc_var is allocated one slot before the first local. | |
| 1222 const intptr_t slot = parsed_function().first_stack_local_index() + 1; | |
| 1223 // If the saved_args_desc_var is captured, it is first moved to the stack | |
| 1224 // and later to the context, once the context is allocated. | |
| 1225 ASSERT(saved_args_desc_var->is_captured() || | |
| 1226 (saved_args_desc_var->index() == slot)); | |
| 1227 __ movl(Address(EBP, slot * kWordSize), kArgumentsDescriptorReg); | |
| 1228 } | |
| 1229 CopyParameters(); | 1213 CopyParameters(); |
| 1230 } | 1214 } |
| 1231 | 1215 |
| 1232 // In unoptimized code, initialize (non-argument) stack allocated slots to | 1216 // In unoptimized code, initialize (non-argument) stack allocated slots to |
| 1233 // null. This does not cover the saved_args_desc_var slot. | 1217 // null. |
| 1234 if (!is_optimizing() && (num_locals > 0)) { | 1218 if (!is_optimizing() && (num_locals > 0)) { |
| 1235 __ Comment("Initialize spill slots"); | 1219 __ Comment("Initialize spill slots"); |
| 1236 const intptr_t slot_base = parsed_function().first_stack_local_index(); | 1220 const intptr_t slot_base = parsed_function().first_stack_local_index(); |
| 1237 const Immediate& raw_null = | 1221 const Immediate& raw_null = |
| 1238 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1222 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1239 __ movl(EAX, raw_null); | 1223 __ movl(EAX, raw_null); |
| 1240 for (intptr_t i = 0; i < num_locals; ++i) { | 1224 for (intptr_t i = 0; i < num_locals; ++i) { |
| 1241 // Subtract index i (locals lie at lower addresses than EBP). | 1225 // Subtract index i (locals lie at lower addresses than EBP). |
| 1242 __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX); | 1226 __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX); |
| 1243 } | 1227 } |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 __ movups(reg, Address(ESP, 0)); | 1940 __ movups(reg, Address(ESP, 0)); |
| 1957 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1941 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1958 } | 1942 } |
| 1959 | 1943 |
| 1960 | 1944 |
| 1961 #undef __ | 1945 #undef __ |
| 1962 | 1946 |
| 1963 } // namespace dart | 1947 } // namespace dart |
| 1964 | 1948 |
| 1965 #endif // defined TARGET_ARCH_IA32 | 1949 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |