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 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 // The call below has an empty stackmap because we have just | 995 // The call below has an empty stackmap because we have just |
996 // dropped the spill slots. | 996 // dropped the spill slots. |
997 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); | 997 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); |
998 | 998 |
999 // Invoke noSuchMethod function passing the original name of the function. | 999 // Invoke noSuchMethod function passing the original name of the function. |
1000 // If the function is a closure function, use "call" as the original name. | 1000 // If the function is a closure function, use "call" as the original name. |
1001 const String& name = String::Handle( | 1001 const String& name = String::Handle( |
1002 function.IsClosureFunction() ? Symbols::Call().raw() : function.name()); | 1002 function.IsClosureFunction() ? Symbols::Call().raw() : function.name()); |
1003 const int kNumArgsChecked = 1; | 1003 const int kNumArgsChecked = 1; |
1004 const ICData& ic_data = ICData::ZoneHandle( | 1004 const ICData& ic_data = ICData::ZoneHandle( |
1005 ICData::New(function, name, Isolate::kNoDeoptId, kNumArgsChecked)); | 1005 ICData::New(function, name, Object::null_array(), |
| 1006 Isolate::kNoDeoptId, kNumArgsChecked)); |
1006 __ LoadObject(RBX, ic_data); | 1007 __ LoadObject(RBX, ic_data); |
1007 // RBP - 8 : PC marker, allows easy identification of RawInstruction obj. | 1008 // RBP - 8 : PC marker, allows easy identification of RawInstruction obj. |
1008 // RBP : points to previous frame pointer. | 1009 // RBP : points to previous frame pointer. |
1009 // RBP + 8 : points to return address. | 1010 // RBP + 8 : points to return address. |
1010 // RBP + 16 : address of last argument (arg n-1). | 1011 // RBP + 16 : address of last argument (arg n-1). |
1011 // RSP + 16 + 8*(n-1) : address of first argument (arg 0). | 1012 // RSP + 16 + 8*(n-1) : address of first argument (arg 0). |
1012 // RBX : ic-data. | 1013 // RBX : ic-data. |
1013 // R10 : arguments descriptor array. | 1014 // R10 : arguments descriptor array. |
1014 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); | 1015 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); |
1015 // Emit descriptors in order to provide correct postion in stacktrace. | 1016 // Emit descriptors in order to provide correct postion in stacktrace. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 // that area on the stack. | 1167 // that area on the stack. |
1167 __ addq(RSP, Immediate(StackSize() * kWordSize)); | 1168 __ addq(RSP, Immediate(StackSize() * kWordSize)); |
1168 } | 1169 } |
1169 // The call below has an empty stackmap because we have just | 1170 // The call below has an empty stackmap because we have just |
1170 // dropped the spill slots. | 1171 // dropped the spill slots. |
1171 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); | 1172 BitmapBuilder* empty_stack_bitmap = new BitmapBuilder(); |
1172 | 1173 |
1173 // Invoke noSuchMethod function passing "call" as the function name. | 1174 // Invoke noSuchMethod function passing "call" as the function name. |
1174 const int kNumArgsChecked = 1; | 1175 const int kNumArgsChecked = 1; |
1175 const ICData& ic_data = ICData::ZoneHandle( | 1176 const ICData& ic_data = ICData::ZoneHandle( |
1176 ICData::New(function, Symbols::Call(), | 1177 ICData::New(function, Symbols::Call(), Object::null_array(), |
1177 Isolate::kNoDeoptId, kNumArgsChecked)); | 1178 Isolate::kNoDeoptId, kNumArgsChecked)); |
1178 __ LoadObject(RBX, ic_data); | 1179 __ LoadObject(RBX, ic_data); |
1179 // RBP - 8 : PC marker, for easy identification of RawInstruction obj. | 1180 // RBP - 8 : PC marker, for easy identification of RawInstruction obj. |
1180 // RBP : points to previous frame pointer. | 1181 // RBP : points to previous frame pointer. |
1181 // RBP + 8 : points to return address. | 1182 // RBP + 8 : points to return address. |
1182 // RBP + 16 : address of last argument (arg n-1). | 1183 // RBP + 16 : address of last argument (arg n-1). |
1183 // RSP + 16 + 8*(n-1) : address of first argument (arg 0). | 1184 // RSP + 16 + 8*(n-1) : address of first argument (arg 0). |
1184 // RBX : ic-data. | 1185 // RBX : ic-data. |
1185 // R10 : arguments descriptor array. | 1186 // R10 : arguments descriptor array. |
1186 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); | 1187 __ call(&StubCode::CallNoSuchMethodFunctionLabel()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 // arguments are removed. | 1309 // arguments are removed. |
1309 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); | 1310 AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); |
1310 } | 1311 } |
1311 } | 1312 } |
1312 } | 1313 } |
1313 | 1314 |
1314 | 1315 |
1315 void FlowGraphCompiler::EmitOptimizedInstanceCall( | 1316 void FlowGraphCompiler::EmitOptimizedInstanceCall( |
1316 ExternalLabel* target_label, | 1317 ExternalLabel* target_label, |
1317 const ICData& ic_data, | 1318 const ICData& ic_data, |
1318 const Array& arguments_descriptor, | |
1319 intptr_t argument_count, | 1319 intptr_t argument_count, |
1320 intptr_t deopt_id, | 1320 intptr_t deopt_id, |
1321 intptr_t token_pos, | 1321 intptr_t token_pos, |
1322 LocationSummary* locs) { | 1322 LocationSummary* locs) { |
1323 // Each ICData propagated from unoptimized to optimized code contains the | 1323 // Each ICData propagated from unoptimized to optimized code contains the |
1324 // function that corresponds to the Dart function of that IC call. Due | 1324 // function that corresponds to the Dart function of that IC call. Due |
1325 // to inlining in optimized code, that function may not correspond to the | 1325 // to inlining in optimized code, that function may not correspond to the |
1326 // top-level function (parsed_function().function()) which could be | 1326 // top-level function (parsed_function().function()) which could be |
1327 // reoptimized and which counter needs to be incremented. | 1327 // reoptimized and which counter needs to be incremented. |
1328 // Pass the function explicitly, it is used in IC stub. | 1328 // Pass the function explicitly, it is used in IC stub. |
1329 __ LoadObject(RDI, parsed_function().function()); | 1329 __ LoadObject(RDI, parsed_function().function()); |
1330 __ LoadObject(RBX, ic_data); | 1330 __ LoadObject(RBX, ic_data); |
1331 __ LoadObject(R10, arguments_descriptor); | |
1332 GenerateDartCall(deopt_id, | 1331 GenerateDartCall(deopt_id, |
1333 token_pos, | 1332 token_pos, |
1334 target_label, | 1333 target_label, |
1335 PcDescriptors::kIcCall, | 1334 PcDescriptors::kIcCall, |
1336 locs); | 1335 locs); |
1337 __ Drop(argument_count); | 1336 __ Drop(argument_count); |
1338 } | 1337 } |
1339 | 1338 |
1340 | 1339 |
1341 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, | 1340 void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, |
1342 const ICData& ic_data, | 1341 const ICData& ic_data, |
1343 const Array& arguments_descriptor, | |
1344 intptr_t argument_count, | 1342 intptr_t argument_count, |
1345 intptr_t deopt_id, | 1343 intptr_t deopt_id, |
1346 intptr_t token_pos, | 1344 intptr_t token_pos, |
1347 LocationSummary* locs) { | 1345 LocationSummary* locs) { |
1348 __ LoadObject(RBX, ic_data); | 1346 __ LoadObject(RBX, ic_data); |
1349 __ LoadObject(R10, arguments_descriptor); | |
1350 GenerateDartCall(deopt_id, | 1347 GenerateDartCall(deopt_id, |
1351 token_pos, | 1348 token_pos, |
1352 target_label, | 1349 target_label, |
1353 PcDescriptors::kIcCall, | 1350 PcDescriptors::kIcCall, |
1354 locs); | 1351 locs); |
1355 __ Drop(argument_count); | 1352 __ Drop(argument_count); |
1356 } | 1353 } |
1357 | 1354 |
1358 | 1355 |
1359 void FlowGraphCompiler::EmitMegamorphicInstanceCall( | 1356 void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
1360 const ICData& ic_data, | 1357 const ICData& ic_data, |
1361 const Array& arguments_descriptor, | |
1362 intptr_t argument_count, | 1358 intptr_t argument_count, |
1363 intptr_t deopt_id, | 1359 intptr_t deopt_id, |
1364 intptr_t token_pos, | 1360 intptr_t token_pos, |
1365 LocationSummary* locs) { | 1361 LocationSummary* locs) { |
1366 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); | 1362 MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table(); |
1367 const String& name = String::Handle(ic_data.target_name()); | 1363 const String& name = String::Handle(ic_data.target_name()); |
| 1364 const Array& arguments_descriptor = |
| 1365 Array::ZoneHandle(ic_data.arguments_descriptor()); |
| 1366 ASSERT(!arguments_descriptor.IsNull()); |
1368 const MegamorphicCache& cache = | 1367 const MegamorphicCache& cache = |
1369 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); | 1368 MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor)); |
1370 Label not_smi, load_cache; | 1369 Label not_smi, load_cache; |
1371 __ movq(RAX, Address(RSP, (argument_count - 1) * kWordSize)); | 1370 __ movq(RAX, Address(RSP, (argument_count - 1) * kWordSize)); |
1372 __ testq(RAX, Immediate(kSmiTagMask)); | 1371 __ testq(RAX, Immediate(kSmiTagMask)); |
1373 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); | 1372 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); |
1374 __ movq(RAX, Immediate(Smi::RawValue(kSmiCid))); | 1373 __ movq(RAX, Immediate(Smi::RawValue(kSmiCid))); |
1375 __ jmp(&load_cache); | 1374 __ jmp(&load_cache); |
1376 | 1375 |
1377 __ Bind(¬_smi); | 1376 __ Bind(¬_smi); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 __ movups(reg, Address(RSP, 0)); | 1903 __ movups(reg, Address(RSP, 0)); |
1905 __ addq(RSP, Immediate(kFpuRegisterSize)); | 1904 __ addq(RSP, Immediate(kFpuRegisterSize)); |
1906 } | 1905 } |
1907 | 1906 |
1908 | 1907 |
1909 #undef __ | 1908 #undef __ |
1910 | 1909 |
1911 } // namespace dart | 1910 } // namespace dart |
1912 | 1911 |
1913 #endif // defined TARGET_ARCH_X64 | 1912 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |