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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 // No such checking code is generated if only fixed parameters are declared, | 1138 // No such checking code is generated if only fixed parameters are declared, |
1139 // unless we are in debug mode or unless we are compiling a closure. | 1139 // unless we are in debug mode or unless we are compiling a closure. |
1140 LocalVariable* saved_args_desc_var = | 1140 LocalVariable* saved_args_desc_var = |
1141 parsed_function().GetSavedArgumentsDescriptorVar(); | 1141 parsed_function().GetSavedArgumentsDescriptorVar(); |
1142 if (num_copied_params == 0) { | 1142 if (num_copied_params == 0) { |
1143 #ifdef DEBUG | 1143 #ifdef DEBUG |
1144 ASSERT(!parsed_function().function().HasOptionalParameters()); | 1144 ASSERT(!parsed_function().function().HasOptionalParameters()); |
1145 const bool check_arguments = !flow_graph().IsCompiledForOsr(); | 1145 const bool check_arguments = !flow_graph().IsCompiledForOsr(); |
1146 #else | 1146 #else |
1147 const bool check_arguments = | 1147 const bool check_arguments = |
1148 function.IsClosureFunction() && !flow_graph().IsCompiledForOsr(); | 1148 (function.IsClosureFunction() || function.IsNoSuchMethodDispatcher()) && |
| 1149 !flow_graph().IsCompiledForOsr(); |
1149 #endif | 1150 #endif |
1150 if (check_arguments) { | 1151 if (check_arguments) { |
1151 __ Comment("Check argument count"); | 1152 __ Comment("Check argument count"); |
1152 // Check that exactly num_fixed arguments are passed in. | 1153 // Check that exactly num_fixed arguments are passed in. |
1153 Label correct_num_arguments, wrong_num_arguments; | 1154 Label correct_num_arguments, wrong_num_arguments; |
1154 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 1155 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
1155 __ cmpq(RAX, Immediate(Smi::RawValue(num_fixed_params))); | 1156 __ cmpq(RAX, Immediate(Smi::RawValue(num_fixed_params))); |
1156 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump); | 1157 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump); |
1157 __ cmpq(RAX, | 1158 __ cmpq(RAX, |
1158 FieldAddress(R10, | 1159 FieldAddress(R10, |
1159 ArgumentsDescriptor::positional_count_offset())); | 1160 ArgumentsDescriptor::positional_count_offset())); |
1160 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump); | 1161 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump); |
1161 | 1162 |
1162 __ Bind(&wrong_num_arguments); | 1163 __ Bind(&wrong_num_arguments); |
1163 if (function.IsClosureFunction()) { | 1164 if (function.IsClosureFunction() || function.IsNoSuchMethodDispatcher()) { |
1164 if (StackSize() != 0) { | 1165 if (StackSize() != 0) { |
1165 // We need to unwind the space we reserved for locals and copied | 1166 // We need to unwind the space we reserved for locals and copied |
1166 // parameters. The NoSuchMethodFunction stub does not expect to see | 1167 // parameters. The NoSuchMethodFunction stub does not expect to see |
1167 // that area on the stack. | 1168 // that area on the stack. |
1168 __ addq(RSP, Immediate(StackSize() * kWordSize)); | 1169 __ addq(RSP, Immediate(StackSize() * kWordSize)); |
1169 } | 1170 } |
1170 // The call below has an empty stackmap because we have just | 1171 // The call below has an empty stackmap because we have just |
1171 // dropped the spill slots. | 1172 // dropped the spill slots. |
1172 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); | 1173 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); |
1173 | 1174 |
1174 // Invoke noSuchMethod function passing "call" as the function name. | 1175 // Invoke noSuchMethod function passing the original function name. |
| 1176 // For closure functions, use "call" as the original name. |
| 1177 const String& name = |
| 1178 String::Handle(function.IsClosureFunction() |
| 1179 ? Symbols::Call().raw() |
| 1180 : function.name()); |
1175 const int kNumArgsChecked = 1; | 1181 const int kNumArgsChecked = 1; |
1176 const ICData& ic_data = ICData::ZoneHandle( | 1182 const ICData& ic_data = ICData::ZoneHandle( |
1177 ICData::New(function, Symbols::Call(), Object::null_array(), | 1183 ICData::New(function, name, Object::null_array(), |
1178 Isolate::kNoDeoptId, kNumArgsChecked)); | 1184 Isolate::kNoDeoptId, kNumArgsChecked)); |
1179 __ LoadObject(RBX, ic_data); | 1185 __ LoadObject(RBX, ic_data); |
1180 // RBP - 8 : PC marker, for easy identification of RawInstruction obj. | 1186 // RBP - 8 : PC marker, for easy identification of RawInstruction obj. |
1181 // RBP : points to previous frame pointer. | 1187 // RBP : points to previous frame pointer. |
1182 // RBP + 8 : points to return address. | 1188 // RBP + 8 : points to return address. |
1183 // RBP + 16 : address of last argument (arg n-1). | 1189 // RBP + 16 : address of last argument (arg n-1). |
1184 // RSP + 16 + 8*(n-1) : address of first argument (arg 0). | 1190 // RSP + 16 + 8*(n-1) : address of first argument (arg 0). |
1185 // RBX : ic-data. | 1191 // RBX : ic-data. |
1186 // R10 : arguments descriptor array. | 1192 // R10 : arguments descriptor array. |
1187 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); | 1193 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 __ movups(reg, Address(RSP, 0)); | 1909 __ movups(reg, Address(RSP, 0)); |
1904 __ addq(RSP, Immediate(kFpuRegisterSize)); | 1910 __ addq(RSP, Immediate(kFpuRegisterSize)); |
1905 } | 1911 } |
1906 | 1912 |
1907 | 1913 |
1908 #undef __ | 1914 #undef __ |
1909 | 1915 |
1910 } // namespace dart | 1916 } // namespace dart |
1911 | 1917 |
1912 #endif // defined TARGET_ARCH_X64 | 1918 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |