| 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 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 const Function& function = parsed_function().function(); | 1111 const Function& function = parsed_function().function(); |
| 1112 | 1112 |
| 1113 const int num_fixed_params = function.num_fixed_parameters(); | 1113 const int num_fixed_params = function.num_fixed_parameters(); |
| 1114 const int num_copied_params = parsed_function().num_copied_params(); | 1114 const int num_copied_params = parsed_function().num_copied_params(); |
| 1115 const int num_locals = parsed_function().num_stack_locals(); | 1115 const int num_locals = parsed_function().num_stack_locals(); |
| 1116 | 1116 |
| 1117 // We check the number of passed arguments when we have to copy them due to | 1117 // We check the number of passed arguments when we have to copy them due to |
| 1118 // the presence of optional parameters. | 1118 // the presence of optional parameters. |
| 1119 // No such checking code is generated if only fixed parameters are declared, | 1119 // No such checking code is generated if only fixed parameters are declared, |
| 1120 // unless we are in debug mode or unless we are compiling a closure. | 1120 // unless we are in debug mode or unless we are compiling a closure. |
| 1121 LocalVariable* saved_args_desc_var = | |
| 1122 parsed_function().GetSavedArgumentsDescriptorVar(); | |
| 1123 if (num_copied_params == 0) { | 1121 if (num_copied_params == 0) { |
| 1124 #ifdef DEBUG | 1122 #ifdef DEBUG |
| 1125 ASSERT(!parsed_function().function().HasOptionalParameters()); | 1123 ASSERT(!parsed_function().function().HasOptionalParameters()); |
| 1126 const bool check_arguments = !flow_graph().IsCompiledForOsr(); | 1124 const bool check_arguments = !flow_graph().IsCompiledForOsr(); |
| 1127 #else | 1125 #else |
| 1128 const bool check_arguments = | 1126 const bool check_arguments = |
| 1129 (function.IsClosureFunction() || function.IsNoSuchMethodDispatcher()) && | 1127 (function.IsClosureFunction() || function.IsNoSuchMethodDispatcher()) && |
| 1130 !flow_graph().IsCompiledForOsr(); | 1128 !flow_graph().IsCompiledForOsr(); |
| 1131 #endif | 1129 #endif |
| 1132 if (check_arguments) { | 1130 if (check_arguments) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1156 __ LoadObject(ECX, ic_data); | 1154 __ LoadObject(ECX, ic_data); |
| 1157 __ LeaveFrame(); // The arguments are still on the stack. | 1155 __ LeaveFrame(); // The arguments are still on the stack. |
| 1158 __ jmp(&StubCode::CallNoSuchMethodFunctionLabel()); | 1156 __ jmp(&StubCode::CallNoSuchMethodFunctionLabel()); |
| 1159 // The noSuchMethod call may return to the caller, but not here. | 1157 // The noSuchMethod call may return to the caller, but not here. |
| 1160 __ int3(); | 1158 __ int3(); |
| 1161 } else { | 1159 } else { |
| 1162 __ Stop("Wrong number of arguments"); | 1160 __ Stop("Wrong number of arguments"); |
| 1163 } | 1161 } |
| 1164 __ Bind(&correct_num_arguments); | 1162 __ Bind(&correct_num_arguments); |
| 1165 } | 1163 } |
| 1166 // The arguments descriptor is never saved in the absence of optional | |
| 1167 // parameters, since any argument definition test would always yield true. | |
| 1168 ASSERT(saved_args_desc_var == NULL); | |
| 1169 } else if (!flow_graph().IsCompiledForOsr()) { | 1164 } else if (!flow_graph().IsCompiledForOsr()) { |
| 1170 if (saved_args_desc_var != NULL) { | |
| 1171 __ Comment("Save arguments descriptor"); | |
| 1172 const Register kArgumentsDescriptorReg = EDX; | |
| 1173 // The saved_args_desc_var is allocated one slot before the first local. | |
| 1174 const intptr_t slot = parsed_function().first_stack_local_index() + 1; | |
| 1175 // If the saved_args_desc_var is captured, it is first moved to the stack | |
| 1176 // and later to the context, once the context is allocated. | |
| 1177 ASSERT(saved_args_desc_var->is_captured() || | |
| 1178 (saved_args_desc_var->index() == slot)); | |
| 1179 __ movl(Address(EBP, slot * kWordSize), kArgumentsDescriptorReg); | |
| 1180 } | |
| 1181 CopyParameters(); | 1165 CopyParameters(); |
| 1182 } | 1166 } |
| 1183 | 1167 |
| 1184 // In unoptimized code, initialize (non-argument) stack allocated slots to | 1168 // In unoptimized code, initialize (non-argument) stack allocated slots to |
| 1185 // null. This does not cover the saved_args_desc_var slot. | 1169 // null. |
| 1186 if (!is_optimizing() && (num_locals > 0)) { | 1170 if (!is_optimizing() && (num_locals > 0)) { |
| 1187 __ Comment("Initialize spill slots"); | 1171 __ Comment("Initialize spill slots"); |
| 1188 const intptr_t slot_base = parsed_function().first_stack_local_index(); | 1172 const intptr_t slot_base = parsed_function().first_stack_local_index(); |
| 1189 const Immediate& raw_null = | 1173 const Immediate& raw_null = |
| 1190 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1174 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1191 __ movl(EAX, raw_null); | 1175 __ movl(EAX, raw_null); |
| 1192 for (intptr_t i = 0; i < num_locals; ++i) { | 1176 for (intptr_t i = 0; i < num_locals; ++i) { |
| 1193 // Subtract index i (locals lie at lower addresses than EBP). | 1177 // Subtract index i (locals lie at lower addresses than EBP). |
| 1194 __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX); | 1178 __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX); |
| 1195 } | 1179 } |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 __ movups(reg, Address(ESP, 0)); | 1892 __ movups(reg, Address(ESP, 0)); |
| 1909 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1893 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1910 } | 1894 } |
| 1911 | 1895 |
| 1912 | 1896 |
| 1913 #undef __ | 1897 #undef __ |
| 1914 | 1898 |
| 1915 } // namespace dart | 1899 } // namespace dart |
| 1916 | 1900 |
| 1917 #endif // defined TARGET_ARCH_IA32 | 1901 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |