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 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 // The call below has an empty stackmap because we have just | 1001 // The call below has an empty stackmap because we have just |
1002 // dropped the spill slots. | 1002 // dropped the spill slots. |
1003 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); | 1003 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); |
1004 | 1004 |
1005 // Invoke noSuchMethod function passing the original name of the function. | 1005 // Invoke noSuchMethod function passing the original name of the function. |
1006 // If the function is a closure function, use "call" as the original name. | 1006 // If the function is a closure function, use "call" as the original name. |
1007 const String& name = String::Handle( | 1007 const String& name = String::Handle( |
1008 function.IsClosureFunction() ? Symbols::Call().raw() : function.name()); | 1008 function.IsClosureFunction() ? Symbols::Call().raw() : function.name()); |
1009 const int kNumArgsChecked = 1; | 1009 const int kNumArgsChecked = 1; |
1010 const ICData& ic_data = ICData::ZoneHandle( | 1010 const ICData& ic_data = ICData::ZoneHandle( |
1011 ICData::New(function, name, Isolate::kNoDeoptId, kNumArgsChecked)); | 1011 ICData::New(function, name, Object::null_array(), |
| 1012 Isolate::kNoDeoptId, kNumArgsChecked)); |
1012 __ LoadObject(ECX, ic_data); | 1013 __ LoadObject(ECX, ic_data); |
1013 // EBP - 4 : PC marker, allows easy identification of RawInstruction obj. | 1014 // EBP - 4 : PC marker, allows easy identification of RawInstruction obj. |
1014 // EBP : points to previous frame pointer. | 1015 // EBP : points to previous frame pointer. |
1015 // EBP + 4 : points to return address. | 1016 // EBP + 4 : points to return address. |
1016 // EBP + 8 : address of last argument (arg n-1). | 1017 // EBP + 8 : address of last argument (arg n-1). |
1017 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). | 1018 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). |
1018 // ECX : ic-data. | 1019 // ECX : ic-data. |
1019 // EDX : arguments descriptor array. | 1020 // EDX : arguments descriptor array. |
1020 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); | 1021 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); |
1021 // Emit descriptors in order to provide correct postion in stacktrace. | 1022 // Emit descriptors in order to provide correct postion in stacktrace. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 // that area on the stack. | 1172 // that area on the stack. |
1172 __ addl(ESP, Immediate(StackSize() * kWordSize)); | 1173 __ addl(ESP, Immediate(StackSize() * kWordSize)); |
1173 } | 1174 } |
1174 // The call below has an empty stackmap because we have just | 1175 // The call below has an empty stackmap because we have just |
1175 // dropped the spill slots. | 1176 // dropped the spill slots. |
1176 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); | 1177 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); |
1177 | 1178 |
1178 // Invoke noSuchMethod function passing "call" as the function name. | 1179 // Invoke noSuchMethod function passing "call" as the function name. |
1179 const int kNumArgsChecked = 1; | 1180 const int kNumArgsChecked = 1; |
1180 const ICData& ic_data = ICData::ZoneHandle( | 1181 const ICData& ic_data = ICData::ZoneHandle( |
1181 ICData::New(function, Symbols::Call(), | 1182 ICData::New(function, Symbols::Call(), Object::null_array(), |
1182 Isolate::kNoDeoptId, kNumArgsChecked)); | 1183 Isolate::kNoDeoptId, kNumArgsChecked)); |
1183 __ LoadObject(ECX, ic_data); | 1184 __ LoadObject(ECX, ic_data); |
1184 // EBP - 4 : PC marker, for easy identification of RawInstruction obj. | 1185 // EBP - 4 : PC marker, for easy identification of RawInstruction obj. |
1185 // EBP : points to previous frame pointer. | 1186 // EBP : points to previous frame pointer. |
1186 // EBP + 4 : points to return address. | 1187 // EBP + 4 : points to return address. |
1187 // EBP + 8 : address of last argument (arg n-1). | 1188 // EBP + 8 : address of last argument (arg n-1). |
1188 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). | 1189 // ESP + 8 + 4*(n-1) : address of first argument (arg 0). |
1189 // ECX : ic-data. | 1190 // ECX : ic-data. |
1190 // EDX : arguments descriptor array. | 1191 // EDX : arguments descriptor array. |
1191 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); | 1192 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 // arguments are removed. | 1314 // arguments are removed. |
1314 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); | 1315 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); |
1315 } | 1316 } |
1316 } | 1317 } |
1317 } | 1318 } |
1318 | 1319 |
1319 | 1320 |
1320 void FlowGraphCompiler::EmitOptimizedInstanceCall( | 1321 void FlowGraphCompiler::EmitOptimizedInstanceCall( |
1321 ExternalLabel* target_label, | 1322 ExternalLabel* target_label, |
1322 const ICData& ic_data, | 1323 const ICData& ic_data, |
1323 const Array& arguments_descriptor, | |
1324 intptr_t argument_count, | 1324 intptr_t argument_count, |
1325 intptr_t deopt_id, | 1325 intptr_t deopt_id, |
1326 intptr_t token_pos, | 1326 intptr_t token_pos, |
1327 LocationSummary* locs) { | 1327 LocationSummary* locs) { |
1328 // Each ICData propagated from unoptimized to optimized code contains the | 1328 // Each ICData propagated from unoptimized to optimized code contains the |
1329 // function that corresponds to the Dart function of that IC call. Due | 1329 // function that corresponds to the Dart function of that IC call. Due |
1330 // to inlining in optimized code, that function may not correspond to the | 1330 // to inlining in optimized code, that function may not correspond to the |
1331 // top-level function (parsed_function().function()) which could be | 1331 // top-level function (parsed_function().function()) which could be |
1332 // reoptimized and which counter needs to be incremented. | 1332 // reoptimized and which counter needs to be incremented. |
1333 // Pass the function explicitly, it is used in IC stub. | 1333 // Pass the function explicitly, it is used in IC stub. |
1334 __ LoadObject(EDI, parsed_function().function()); | 1334 __ LoadObject(EDI, parsed_function().function()); |
1335 __ LoadObject(ECX, ic_data); | 1335 __ LoadObject(ECX, ic_data); |
1336 __ LoadObject(EDX, arguments_descriptor); | |
1337 GenerateDartCall(deopt_id, | 1336 GenerateDartCall(deopt_id, |
1338 token_pos, | 1337 token_pos, |
1339 target_label, | 1338 target_label, |
1340 PcDescriptors::kIcCall, | 1339 PcDescriptors::kIcCall, |
1341 locs); | 1340 locs); |
1342 __ Drop(argument_count); | 1341 __ Drop(argument_count); |
1343 } | 1342 } |
1344 | 1343 |
1345 | 1344 |
1346 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, | 1345 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, |
1347 const ICData& ic_data, | 1346 const ICData& ic_data, |
1348 const Array& arguments_descriptor, | |
1349 intptr_t argument_count, | 1347 intptr_t argument_count, |
1350 intptr_t deopt_id, | 1348 intptr_t deopt_id, |
1351 intptr_t token_pos, | 1349 intptr_t token_pos, |
1352 LocationSummary* locs) { | 1350 LocationSummary* locs) { |
1353 __ LoadObject(ECX, ic_data); | 1351 __ LoadObject(ECX, ic_data); |
1354 __ LoadObject(EDX, arguments_descriptor); | |
1355 GenerateDartCall(deopt_id, | 1352 GenerateDartCall(deopt_id, |
1356 token_pos, | 1353 token_pos, |
1357 target_label, | 1354 target_label, |
1358 PcDescriptors::kIcCall, | 1355 PcDescriptors::kIcCall, |
1359 locs); | 1356 locs); |
1360 __ Drop(argument_count); | 1357 __ Drop(argument_count); |
1361 } | 1358 } |
1362 | 1359 |
1363 | 1360 |
1364 void FlowGraphCompiler::EmitMegamorphicInstanceCall( | 1361 void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
1365 const ICData& ic_data, | 1362 const ICData& ic_data, |
1366 const Array& arguments_descriptor, | |
1367 intptr_t argument_count, | 1363 intptr_t argument_count, |
1368 intptr_t deopt_id, | 1364 intptr_t deopt_id, |
1369 intptr_t token_pos, | 1365 intptr_t token_pos, |
1370 LocationSummary* locs) { | 1366 LocationSummary* locs) { |
1371 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); | 1367 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); |
1372 const String& name = String::Handle(ic_data.target_name()); | 1368 const String& name = String::Handle(ic_data.target_name()); |
| 1369 const Array& arguments_descriptor = |
| 1370 Array::ZoneHandle(ic_data.arguments_descriptor()); |
| 1371 ASSERT(!arguments_descriptor.IsNull()); |
1373 const MegamorphicCache& cache = | 1372 const MegamorphicCache& cache = |
1374 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); | 1373 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); |
1375 Label not_smi, load_cache; | 1374 Label not_smi, load_cache; |
1376 __ movl(EAX, Address(ESP, (argument_count - 1) * kWordSize)); | 1375 __ movl(EAX, Address(ESP, (argument_count - 1) * kWordSize)); |
1377 __ testl(EAX, Immediate(kSmiTagMask)); | 1376 __ testl(EAX, Immediate(kSmiTagMask)); |
1378 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); | 1377 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); |
1379 __ movl(EAX, Immediate(Smi::RawValue(kSmiCid))); | 1378 __ movl(EAX, Immediate(Smi::RawValue(kSmiCid))); |
1380 __ jmp(&load_cache); | 1379 __ jmp(&load_cache); |
1381 | 1380 |
1382 __ Bind(¬_smi); | 1381 __ Bind(¬_smi); |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1925 __ movups(reg, Address(ESP, 0)); | 1924 __ movups(reg, Address(ESP, 0)); |
1926 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1925 __ addl(ESP, Immediate(kFpuRegisterSize)); |
1927 } | 1926 } |
1928 | 1927 |
1929 | 1928 |
1930 #undef __ | 1929 #undef __ |
1931 | 1930 |
1932 } // namespace dart | 1931 } // namespace dart |
1933 | 1932 |
1934 #endif // defined TARGET_ARCH_IA32 | 1933 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |