| 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 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 __ Bind(&next_parameter); | 985 __ Bind(&next_parameter); |
| 986 } | 986 } |
| 987 __ movl(EBX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); | 987 __ movl(EBX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); |
| 988 __ SmiUntag(EBX); | 988 __ SmiUntag(EBX); |
| 989 // Check that ECX equals EBX, i.e. no named arguments passed. | 989 // Check that ECX equals EBX, i.e. no named arguments passed. |
| 990 __ cmpl(ECX, EBX); | 990 __ cmpl(ECX, EBX); |
| 991 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); | 991 __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); |
| 992 } | 992 } |
| 993 | 993 |
| 994 __ Bind(&wrong_num_arguments); | 994 __ Bind(&wrong_num_arguments); |
| 995 if (StackSize() != 0) { | |
| 996 // We need to unwind the space we reserved for locals and copied parameters. | |
| 997 // The NoSuchMethodFunction stub does not expect to see that area on the | |
| 998 // stack. | |
| 999 __ addl(ESP, Immediate(StackSize() * kWordSize)); | |
| 1000 } | |
| 1001 // The call below has an empty stackmap because we have just | |
| 1002 // dropped the spill slots. | |
| 1003 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); | |
| 1004 | |
| 1005 // Invoke noSuchMethod function passing the original name of the function. | 995 // Invoke noSuchMethod function passing the original name of the function. |
| 1006 // If the function is a closure function, use "call" as the original name. | 996 // If the function is a closure function, use "call" as the original name. |
| 1007 const String& name = String::Handle( | 997 const String& name = String::Handle( |
| 1008 function.IsClosureFunction() ? Symbols::Call().raw() : function.name()); | 998 function.IsClosureFunction() ? Symbols::Call().raw() : function.name()); |
| 1009 const int kNumArgsChecked = 1; | 999 const int kNumArgsChecked = 1; |
| 1010 const ICData& ic_data = ICData::ZoneHandle( | 1000 const ICData& ic_data = ICData::ZoneHandle( |
| 1011 ICData::New(function, name, Object::null_array(), | 1001 ICData::New(function, name, Object::null_array(), |
| 1012 Isolate::kNoDeoptId, kNumArgsChecked)); | 1002 Isolate::kNoDeoptId, kNumArgsChecked)); |
| 1013 __ LoadObject(ECX, ic_data); | 1003 __ LoadObject(ECX, ic_data); |
| 1014 // EBP - 4 : PC marker, allows easy identification of RawInstruction obj. | 1004 __ LeaveFrame(); // The arguments are still on the stack. |
| 1015 // EBP : points to previous frame pointer. | 1005 __ jmp(&StubCode::CallNoSuchMethodFunctionLabel()); |
| 1016 // EBP + 4 : points to return address. | 1006 // The noSuchMethod call may return to the caller, but not here. |
| 1017 // EBP + 8 : address of last argument (arg n-1). | 1007 __ int3(); |
| 1018 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). | |
| 1019 // ECX : ic-data. | |
| 1020 // EDX : arguments descriptor array. | |
| 1021 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); | |
| 1022 // Emit descriptors in order to provide correct postion in stacktrace. | |
| 1023 AddCurrentDescriptor(PcDescriptors::kOther, -1, function.token_pos()); | |
| 1024 if (is_optimizing()) { | |
| 1025 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), | |
| 1026 empty_stack_bitmap, | |
| 1027 0); // No registers. | |
| 1028 } | |
| 1029 // The noSuchMethod call may return. | |
| 1030 __ LeaveFrame(); | |
| 1031 __ ret(); | |
| 1032 | 1008 |
| 1033 __ Bind(&all_arguments_processed); | 1009 __ Bind(&all_arguments_processed); |
| 1034 // Nullify originally passed arguments only after they have been copied and | 1010 // Nullify originally passed arguments only after they have been copied and |
| 1035 // checked, otherwise noSuchMethod would not see their original values. | 1011 // checked, otherwise noSuchMethod would not see their original values. |
| 1036 // This step can be skipped in case we decide that formal parameters are | 1012 // This step can be skipped in case we decide that formal parameters are |
| 1037 // implicitly final, since garbage collecting the unmodified value is not | 1013 // implicitly final, since garbage collecting the unmodified value is not |
| 1038 // an issue anymore. | 1014 // an issue anymore. |
| 1039 | 1015 |
| 1040 // EDX : arguments descriptor array. | 1016 // EDX : arguments descriptor array. |
| 1041 __ movl(ECX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); | 1017 __ movl(ECX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 __ movl(EAX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); | 1136 __ movl(EAX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); |
| 1161 __ cmpl(EAX, Immediate(Smi::RawValue(num_fixed_params))); | 1137 __ cmpl(EAX, Immediate(Smi::RawValue(num_fixed_params))); |
| 1162 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump); | 1138 __ j(NOT_EQUAL, &wrong_num_arguments, Assembler::kNearJump); |
| 1163 __ cmpl(EAX, | 1139 __ cmpl(EAX, |
| 1164 FieldAddress(EDX, | 1140 FieldAddress(EDX, |
| 1165 ArgumentsDescriptor::positional_count_offset())); | 1141 ArgumentsDescriptor::positional_count_offset())); |
| 1166 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump); | 1142 __ j(EQUAL, &correct_num_arguments, Assembler::kNearJump); |
| 1167 | 1143 |
| 1168 __ Bind(&wrong_num_arguments); | 1144 __ Bind(&wrong_num_arguments); |
| 1169 if (function.IsClosureFunction() || function.IsNoSuchMethodDispatcher()) { | 1145 if (function.IsClosureFunction() || function.IsNoSuchMethodDispatcher()) { |
| 1170 if (StackSize() != 0) { | |
| 1171 // We need to unwind the space we reserved for locals and copied | |
| 1172 // parameters. The NoSuchMethodFunction stub does not expect to see | |
| 1173 // that area on the stack. | |
| 1174 __ addl(ESP, Immediate(StackSize() * kWordSize)); | |
| 1175 } | |
| 1176 // The call below has an empty stackmap because we have just | |
| 1177 // dropped the spill slots. | |
| 1178 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); | |
| 1179 | |
| 1180 // Invoke noSuchMethod function passing the original function name. | 1146 // Invoke noSuchMethod function passing the original function name. |
| 1181 // For closure functions, use "call" as the original name. | 1147 // For closure functions, use "call" as the original name. |
| 1182 const String& name = | 1148 const String& name = |
| 1183 String::Handle(function.IsClosureFunction() | 1149 String::Handle(function.IsClosureFunction() |
| 1184 ? Symbols::Call().raw() | 1150 ? Symbols::Call().raw() |
| 1185 : function.name()); | 1151 : function.name()); |
| 1186 const int kNumArgsChecked = 1; | 1152 const int kNumArgsChecked = 1; |
| 1187 const ICData& ic_data = ICData::ZoneHandle( | 1153 const ICData& ic_data = ICData::ZoneHandle( |
| 1188 ICData::New(function, name, Object::null_array(), | 1154 ICData::New(function, name, Object::null_array(), |
| 1189 Isolate::kNoDeoptId, kNumArgsChecked)); | 1155 Isolate::kNoDeoptId, kNumArgsChecked)); |
| 1190 __ LoadObject(ECX, ic_data); | 1156 __ LoadObject(ECX, ic_data); |
| 1191 // EBP - 4 : PC marker, for easy identification of RawInstruction obj. | 1157 __ LeaveFrame(); // The arguments are still on the stack. |
| 1192 // EBP : points to previous frame pointer. | 1158 __ jmp(&StubCode::CallNoSuchMethodFunctionLabel()); |
| 1193 // EBP + 4 : points to return address. | 1159 // The noSuchMethod call may return to the caller, but not here. |
| 1194 // EBP + 8 : address of last argument (arg n-1). | 1160 __ int3(); |
| 1195 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). | |
| 1196 // ECX : ic-data. | |
| 1197 // EDX : arguments descriptor array. | |
| 1198 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); | |
| 1199 // Emit descriptors in order to provide correct postion in stacktrace. | |
| 1200 AddCurrentDescriptor(PcDescriptors::kOther, -1, function.token_pos()); | |
| 1201 if (is_optimizing()) { | |
| 1202 stackmap_table_builder_->AddEntry(assembler()->CodeSize(), | |
| 1203 empty_stack_bitmap, | |
| 1204 0); // No registers. | |
| 1205 } | |
| 1206 // The noSuchMethod call may return. | |
| 1207 __ LeaveFrame(); | |
| 1208 __ ret(); | |
| 1209 } else { | 1161 } else { |
| 1210 __ Stop("Wrong number of arguments"); | 1162 __ Stop("Wrong number of arguments"); |
| 1211 } | 1163 } |
| 1212 __ Bind(&correct_num_arguments); | 1164 __ Bind(&correct_num_arguments); |
| 1213 } | 1165 } |
| 1214 // The arguments descriptor is never saved in the absence of optional | 1166 // The arguments descriptor is never saved in the absence of optional |
| 1215 // parameters, since any argument definition test would always yield true. | 1167 // parameters, since any argument definition test would always yield true. |
| 1216 ASSERT(saved_args_desc_var == NULL); | 1168 ASSERT(saved_args_desc_var == NULL); |
| 1217 } else if (!flow_graph().IsCompiledForOsr()) { | 1169 } else if (!flow_graph().IsCompiledForOsr()) { |
| 1218 if (saved_args_desc_var != NULL) { | 1170 if (saved_args_desc_var != NULL) { |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 __ movups(reg, Address(ESP, 0)); | 1908 __ movups(reg, Address(ESP, 0)); |
| 1957 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1909 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1958 } | 1910 } |
| 1959 | 1911 |
| 1960 | 1912 |
| 1961 #undef __ | 1913 #undef __ |
| 1962 | 1914 |
| 1963 } // namespace dart | 1915 } // namespace dart |
| 1964 | 1916 |
| 1965 #endif // defined TARGET_ARCH_IA32 | 1917 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |