| 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 "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 if (is_optimizing()) { | 1180 if (is_optimizing()) { |
| 1181 AddDeoptIndexAtCall(deopt_id_after, token_pos); | 1181 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
| 1182 } else { | 1182 } else { |
| 1183 // Add deoptimization continuation point after the call and before the | 1183 // Add deoptimization continuation point after the call and before the |
| 1184 // arguments are removed. | 1184 // arguments are removed. |
| 1185 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1185 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
| 1186 } | 1186 } |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 | 1189 |
| 1190 void FlowGraphCompiler::GenerateStaticDartCall(intptr_t deopt_id, |
| 1191 TokenPosition token_pos, |
| 1192 const StubEntry& stub_entry, |
| 1193 RawPcDescriptors::Kind kind, |
| 1194 LocationSummary* locs, |
| 1195 const Function& target) { |
| 1196 // Call sites to the same target can share object pool entries. These |
| 1197 // call sites are never patched for breakpoints: the function is deoptimized |
| 1198 // and the unoptimized code with IC calls for static calls is patched instead. |
| 1199 ASSERT(is_optimizing()); |
| 1200 __ CallWithEquivalence(stub_entry, target); |
| 1201 |
| 1202 AddCurrentDescriptor(kind, deopt_id, token_pos); |
| 1203 RecordSafepoint(locs); |
| 1204 // Marks either the continuation point in unoptimized code or the |
| 1205 // deoptimization point in optimized code, after call. |
| 1206 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); |
| 1207 if (is_optimizing()) { |
| 1208 AddDeoptIndexAtCall(deopt_id_after, token_pos); |
| 1209 } else { |
| 1210 // Add deoptimization continuation point after the call and before the |
| 1211 // arguments are removed. |
| 1212 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
| 1213 } |
| 1214 AddStaticCallTarget(target); |
| 1215 } |
| 1216 |
| 1217 |
| 1190 void FlowGraphCompiler::GenerateRuntimeCall(TokenPosition token_pos, | 1218 void FlowGraphCompiler::GenerateRuntimeCall(TokenPosition token_pos, |
| 1191 intptr_t deopt_id, | 1219 intptr_t deopt_id, |
| 1192 const RuntimeEntry& entry, | 1220 const RuntimeEntry& entry, |
| 1193 intptr_t argument_count, | 1221 intptr_t argument_count, |
| 1194 LocationSummary* locs) { | 1222 LocationSummary* locs) { |
| 1195 __ CallRuntime(entry, argument_count); | 1223 __ CallRuntime(entry, argument_count); |
| 1196 AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); | 1224 AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); |
| 1197 RecordSafepoint(locs); | 1225 RecordSafepoint(locs); |
| 1198 if (deopt_id != Thread::kNoDeoptId) { | 1226 if (deopt_id != Thread::kNoDeoptId) { |
| 1199 // Marks either the continuation point in unoptimized code or the | 1227 // Marks either the continuation point in unoptimized code or the |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 void FlowGraphCompiler::EmitOptimizedStaticCall( | 1407 void FlowGraphCompiler::EmitOptimizedStaticCall( |
| 1380 const Function& function, | 1408 const Function& function, |
| 1381 const Array& arguments_descriptor, | 1409 const Array& arguments_descriptor, |
| 1382 intptr_t argument_count, | 1410 intptr_t argument_count, |
| 1383 intptr_t deopt_id, | 1411 intptr_t deopt_id, |
| 1384 TokenPosition token_pos, | 1412 TokenPosition token_pos, |
| 1385 LocationSummary* locs) { | 1413 LocationSummary* locs) { |
| 1386 __ LoadObject(R10, arguments_descriptor); | 1414 __ LoadObject(R10, arguments_descriptor); |
| 1387 // Do not use the code from the function, but let the code be patched so that | 1415 // Do not use the code from the function, but let the code be patched so that |
| 1388 // we can record the outgoing edges to other code. | 1416 // we can record the outgoing edges to other code. |
| 1389 GenerateDartCall(deopt_id, | 1417 GenerateStaticDartCall(deopt_id, |
| 1390 token_pos, | 1418 token_pos, |
| 1391 *StubCode::CallStaticFunction_entry(), | 1419 *StubCode::CallStaticFunction_entry(), |
| 1392 RawPcDescriptors::kOther, | 1420 RawPcDescriptors::kOther, |
| 1393 locs); | 1421 locs, |
| 1394 AddStaticCallTarget(function); | 1422 function); |
| 1395 __ Drop(argument_count, RCX); | 1423 __ Drop(argument_count, RCX); |
| 1396 } | 1424 } |
| 1397 | 1425 |
| 1398 | 1426 |
| 1399 Condition FlowGraphCompiler::EmitEqualityRegConstCompare( | 1427 Condition FlowGraphCompiler::EmitEqualityRegConstCompare( |
| 1400 Register reg, | 1428 Register reg, |
| 1401 const Object& obj, | 1429 const Object& obj, |
| 1402 bool needs_number_check, | 1430 bool needs_number_check, |
| 1403 TokenPosition token_pos) { | 1431 TokenPosition token_pos) { |
| 1404 ASSERT(!needs_number_check || | 1432 ASSERT(!needs_number_check || |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 __ testq(RAX, Immediate(kSmiTagMask)); | 1552 __ testq(RAX, Immediate(kSmiTagMask)); |
| 1525 if (kFirstCheckIsSmi) { | 1553 if (kFirstCheckIsSmi) { |
| 1526 // Jump if receiver is not Smi. | 1554 // Jump if receiver is not Smi. |
| 1527 if (kNumChecks == 1) { | 1555 if (kNumChecks == 1) { |
| 1528 __ j(NOT_ZERO, failed); | 1556 __ j(NOT_ZERO, failed); |
| 1529 } else { | 1557 } else { |
| 1530 __ j(NOT_ZERO, &after_smi_test); | 1558 __ j(NOT_ZERO, &after_smi_test); |
| 1531 } | 1559 } |
| 1532 // Do not use the code from the function, but let the code be patched so | 1560 // Do not use the code from the function, but let the code be patched so |
| 1533 // that we can record the outgoing edges to other code. | 1561 // that we can record the outgoing edges to other code. |
| 1534 GenerateDartCall(deopt_id, | |
| 1535 token_index, | |
| 1536 *StubCode::CallStaticFunction_entry(), | |
| 1537 RawPcDescriptors::kOther, | |
| 1538 locs); | |
| 1539 const Function& function = Function::ZoneHandle( | 1562 const Function& function = Function::ZoneHandle( |
| 1540 zone(), ic_data.GetTargetAt(0)); | 1563 zone(), ic_data.GetTargetAt(0)); |
| 1541 AddStaticCallTarget(function); | 1564 GenerateStaticDartCall(deopt_id, |
| 1565 token_index, |
| 1566 *StubCode::CallStaticFunction_entry(), |
| 1567 RawPcDescriptors::kOther, |
| 1568 locs, |
| 1569 function); |
| 1542 __ Drop(argument_count, RCX); | 1570 __ Drop(argument_count, RCX); |
| 1543 if (kNumChecks > 1) { | 1571 if (kNumChecks > 1) { |
| 1544 __ jmp(match_found); | 1572 __ jmp(match_found); |
| 1545 } | 1573 } |
| 1546 } else { | 1574 } else { |
| 1547 // Receiver is Smi, but Smi is not a valid class therefore fail. | 1575 // Receiver is Smi, but Smi is not a valid class therefore fail. |
| 1548 // (Smi class must be first in the list). | 1576 // (Smi class must be first in the list). |
| 1549 __ j(ZERO, failed); | 1577 __ j(ZERO, failed); |
| 1550 } | 1578 } |
| 1551 __ Bind(&after_smi_test); | 1579 __ Bind(&after_smi_test); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1566 ASSERT(sorted[i].cid != kSmiCid); | 1594 ASSERT(sorted[i].cid != kSmiCid); |
| 1567 Label next_test; | 1595 Label next_test; |
| 1568 __ cmpl(RDI, Immediate(sorted[i].cid)); | 1596 __ cmpl(RDI, Immediate(sorted[i].cid)); |
| 1569 if (kIsLastCheck) { | 1597 if (kIsLastCheck) { |
| 1570 __ j(NOT_EQUAL, failed); | 1598 __ j(NOT_EQUAL, failed); |
| 1571 } else { | 1599 } else { |
| 1572 __ j(NOT_EQUAL, &next_test); | 1600 __ j(NOT_EQUAL, &next_test); |
| 1573 } | 1601 } |
| 1574 // Do not use the code from the function, but let the code be patched so | 1602 // Do not use the code from the function, but let the code be patched so |
| 1575 // that we can record the outgoing edges to other code. | 1603 // that we can record the outgoing edges to other code. |
| 1576 GenerateDartCall(deopt_id, | |
| 1577 token_index, | |
| 1578 *StubCode::CallStaticFunction_entry(), | |
| 1579 RawPcDescriptors::kOther, | |
| 1580 locs); | |
| 1581 const Function& function = *sorted[i].target; | 1604 const Function& function = *sorted[i].target; |
| 1582 AddStaticCallTarget(function); | 1605 GenerateStaticDartCall(deopt_id, |
| 1606 token_index, |
| 1607 *StubCode::CallStaticFunction_entry(), |
| 1608 RawPcDescriptors::kOther, |
| 1609 locs, |
| 1610 function); |
| 1583 __ Drop(argument_count, RCX); | 1611 __ Drop(argument_count, RCX); |
| 1584 if (!kIsLastCheck) { | 1612 if (!kIsLastCheck) { |
| 1585 __ jmp(match_found); | 1613 __ jmp(match_found); |
| 1586 } | 1614 } |
| 1587 __ Bind(&next_test); | 1615 __ Bind(&next_test); |
| 1588 } | 1616 } |
| 1589 } | 1617 } |
| 1590 | 1618 |
| 1591 | 1619 |
| 1592 #undef __ | 1620 #undef __ |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1820 __ movups(reg, Address(RSP, 0)); | 1848 __ movups(reg, Address(RSP, 0)); |
| 1821 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); | 1849 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); |
| 1822 } | 1850 } |
| 1823 | 1851 |
| 1824 | 1852 |
| 1825 #undef __ | 1853 #undef __ |
| 1826 | 1854 |
| 1827 } // namespace dart | 1855 } // namespace dart |
| 1828 | 1856 |
| 1829 #endif // defined TARGET_ARCH_X64 | 1857 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |