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 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 __ popq(left); | 1441 __ popq(left); |
1442 } else { | 1442 } else { |
1443 __ cmpl(left, right); | 1443 __ cmpl(left, right); |
1444 } | 1444 } |
1445 } | 1445 } |
1446 | 1446 |
1447 | 1447 |
1448 // This function must be in sync with FlowGraphCompiler::RecordSafepoint and | 1448 // This function must be in sync with FlowGraphCompiler::RecordSafepoint and |
1449 // FlowGraphCompiler::SlowPathEnvironmentFor. | 1449 // FlowGraphCompiler::SlowPathEnvironmentFor. |
1450 void FlowGraphCompiler::SaveLiveRegisters(LocationSummary* locs) { | 1450 void FlowGraphCompiler::SaveLiveRegisters(LocationSummary* locs) { |
1451 // TODO(vegorov): consider saving only caller save (volatile) registers. | 1451 // TODO(vegorov): avoid saving non-volatile registers. |
1452 const intptr_t xmm_regs_count = locs->live_registers()->FpuRegisterCount(); | 1452 __ PushRegisters(locs->live_registers()->cpu_registers(), |
1453 if (xmm_regs_count > 0) { | 1453 locs->live_registers()->fpu_registers()); |
1454 __ AddImmediate(RSP, Immediate(-xmm_regs_count * kFpuRegisterSize), PP); | |
1455 // Store XMM registers with the lowest register number at the lowest | |
1456 // address. | |
1457 intptr_t offset = 0; | |
1458 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { | |
1459 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); | |
1460 if (locs->live_registers()->ContainsFpuRegister(xmm_reg)) { | |
1461 __ movups(Address(RSP, offset), xmm_reg); | |
1462 offset += kFpuRegisterSize; | |
1463 } | |
1464 } | |
1465 ASSERT(offset == (xmm_regs_count * kFpuRegisterSize)); | |
1466 } | |
1467 | |
1468 // Store general purpose registers with the highest register number at the | |
1469 // lowest address. | |
1470 for (intptr_t reg_idx = 0; reg_idx < kNumberOfCpuRegisters; ++reg_idx) { | |
1471 Register reg = static_cast<Register>(reg_idx); | |
1472 if (locs->live_registers()->ContainsRegister(reg)) { | |
1473 __ pushq(reg); | |
1474 } | |
1475 } | |
1476 } | 1454 } |
1477 | 1455 |
1478 | 1456 |
1479 void FlowGraphCompiler::RestoreLiveRegisters(LocationSummary* locs) { | 1457 void FlowGraphCompiler::RestoreLiveRegisters(LocationSummary* locs) { |
1480 // General purpose registers have the highest register number at the | 1458 __ PopRegisters(locs->live_registers()->cpu_registers(), |
1481 // lowest address. | 1459 locs->live_registers()->fpu_registers()); |
1482 for (intptr_t reg_idx = kNumberOfCpuRegisters - 1; reg_idx >= 0; --reg_idx) { | |
1483 Register reg = static_cast<Register>(reg_idx); | |
1484 if (locs->live_registers()->ContainsRegister(reg)) { | |
1485 __ popq(reg); | |
1486 } | |
1487 } | |
1488 | |
1489 const intptr_t xmm_regs_count = locs->live_registers()->FpuRegisterCount(); | |
1490 if (xmm_regs_count > 0) { | |
1491 // XMM registers have the lowest register number at the lowest address. | |
1492 intptr_t offset = 0; | |
1493 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { | |
1494 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); | |
1495 if (locs->live_registers()->ContainsFpuRegister(xmm_reg)) { | |
1496 __ movups(xmm_reg, Address(RSP, offset)); | |
1497 offset += kFpuRegisterSize; | |
1498 } | |
1499 } | |
1500 ASSERT(offset == (xmm_regs_count * kFpuRegisterSize)); | |
1501 __ AddImmediate(RSP, Immediate(offset), PP); | |
1502 } | |
1503 } | 1460 } |
1504 | 1461 |
1505 | 1462 |
1506 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, | 1463 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, |
1507 Register class_id_reg, | 1464 Register class_id_reg, |
1508 intptr_t argument_count, | 1465 intptr_t argument_count, |
1509 const Array& argument_names, | 1466 const Array& argument_names, |
1510 Label* deopt, | 1467 Label* deopt, |
1511 intptr_t deopt_id, | 1468 intptr_t deopt_id, |
1512 intptr_t token_index, | 1469 intptr_t token_index, |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 __ movups(reg, Address(RSP, 0)); | 1718 __ movups(reg, Address(RSP, 0)); |
1762 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); | 1719 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); |
1763 } | 1720 } |
1764 | 1721 |
1765 | 1722 |
1766 #undef __ | 1723 #undef __ |
1767 | 1724 |
1768 } // namespace dart | 1725 } // namespace dart |
1769 | 1726 |
1770 #endif // defined TARGET_ARCH_X64 | 1727 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |