OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 __ call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1462 __ call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
1463 } | 1463 } |
1464 | 1464 |
1465 | 1465 |
1466 void CodeGenerator::AssemblePrologue() { | 1466 void CodeGenerator::AssemblePrologue() { |
1467 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1467 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1468 int stack_slots = frame()->GetSpillSlotCount(); | 1468 int stack_slots = frame()->GetSpillSlotCount(); |
1469 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1469 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1470 __ pushq(rbp); | 1470 __ pushq(rbp); |
1471 __ movq(rbp, rsp); | 1471 __ movq(rbp, rsp); |
| 1472 int register_save_area_size = 0; |
1472 const RegList saves = descriptor->CalleeSavedRegisters(); | 1473 const RegList saves = descriptor->CalleeSavedRegisters(); |
1473 if (saves != 0) { // Save callee-saved registers. | 1474 if (saves != 0) { // Save callee-saved registers. |
1474 int register_save_area_size = 0; | |
1475 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | 1475 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { |
1476 if (!((1 << i) & saves)) continue; | 1476 if (!((1 << i) & saves)) continue; |
1477 __ pushq(Register::from_code(i)); | 1477 __ pushq(Register::from_code(i)); |
1478 register_save_area_size += kPointerSize; | 1478 register_save_area_size += kPointerSize; |
1479 } | 1479 } |
| 1480 } |
| 1481 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); |
| 1482 if (saves_fp != 0) { // Save callee-saved XMM registers. |
| 1483 const uint32_t saves_fp_count = base::bits::CountPopulation32(saves_fp); |
| 1484 const int stack_size = saves_fp_count * 16; |
| 1485 // Adjust the stack pointer. |
| 1486 __ subp(rsp, Immediate(stack_size)); |
| 1487 // Store the registers on the stack. |
| 1488 int slot_idx = 0; |
| 1489 for (int i = 0; i < XMMRegister::kMaxNumRegisters; i++) { |
| 1490 if (!((1 << i) & saves_fp)) continue; |
| 1491 __ movdqu(Operand(rsp, 16 * slot_idx), XMMRegister::from_code(i)); |
| 1492 slot_idx++; |
| 1493 } |
| 1494 register_save_area_size += stack_size; |
| 1495 } |
| 1496 if (register_save_area_size > 0) { |
1480 frame()->SetRegisterSaveAreaSize(register_save_area_size); | 1497 frame()->SetRegisterSaveAreaSize(register_save_area_size); |
1481 } | 1498 } |
1482 } else if (descriptor->IsJSFunctionCall()) { | 1499 } else if (descriptor->IsJSFunctionCall()) { |
1483 CompilationInfo* info = this->info(); | 1500 CompilationInfo* info = this->info(); |
1484 __ Prologue(info->IsCodePreAgingActive()); | 1501 __ Prologue(info->IsCodePreAgingActive()); |
1485 frame()->SetRegisterSaveAreaSize( | 1502 frame()->SetRegisterSaveAreaSize( |
1486 StandardFrameConstants::kFixedFrameSizeFromFp); | 1503 StandardFrameConstants::kFixedFrameSizeFromFp); |
1487 } else if (needs_frame_) { | 1504 } else if (needs_frame_) { |
1488 __ StubPrologue(); | 1505 __ StubPrologue(); |
1489 frame()->SetRegisterSaveAreaSize( | 1506 frame()->SetRegisterSaveAreaSize( |
(...skipping 24 matching lines...) Expand all Loading... |
1514 | 1531 |
1515 void CodeGenerator::AssembleReturn() { | 1532 void CodeGenerator::AssembleReturn() { |
1516 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1533 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1517 int stack_slots = frame()->GetSpillSlotCount(); | 1534 int stack_slots = frame()->GetSpillSlotCount(); |
1518 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1535 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1519 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1536 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1520 // Remove this frame's spill slots first. | 1537 // Remove this frame's spill slots first. |
1521 if (stack_slots > 0) { | 1538 if (stack_slots > 0) { |
1522 __ addq(rsp, Immediate(stack_slots * kPointerSize)); | 1539 __ addq(rsp, Immediate(stack_slots * kPointerSize)); |
1523 } | 1540 } |
| 1541 // Restore registers. |
| 1542 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); |
| 1543 if (saves_fp != 0) { |
| 1544 const uint32_t saves_fp_count = base::bits::CountPopulation32(saves_fp); |
| 1545 const int stack_size = saves_fp_count * 16; |
| 1546 // Load the registers from the stack. |
| 1547 int slot_idx = 0; |
| 1548 for (int i = 0; i < XMMRegister::kMaxNumRegisters; i++) { |
| 1549 if (!((1 << i) & saves_fp)) continue; |
| 1550 __ movdqu(XMMRegister::from_code(i), Operand(rsp, 16 * slot_idx)); |
| 1551 slot_idx++; |
| 1552 } |
| 1553 // Adjust the stack pointer. |
| 1554 __ addp(rsp, Immediate(stack_size)); |
| 1555 } |
1524 const RegList saves = descriptor->CalleeSavedRegisters(); | 1556 const RegList saves = descriptor->CalleeSavedRegisters(); |
1525 // Restore registers. | |
1526 if (saves != 0) { | 1557 if (saves != 0) { |
1527 for (int i = 0; i < Register::kNumRegisters; i++) { | 1558 for (int i = 0; i < Register::kNumRegisters; i++) { |
1528 if (!((1 << i) & saves)) continue; | 1559 if (!((1 << i) & saves)) continue; |
1529 __ popq(Register::from_code(i)); | 1560 __ popq(Register::from_code(i)); |
1530 } | 1561 } |
1531 } | 1562 } |
1532 __ popq(rbp); // Pop caller's frame pointer. | 1563 __ popq(rbp); // Pop caller's frame pointer. |
1533 __ ret(0); | 1564 __ ret(0); |
1534 } else { | 1565 } else { |
1535 // No saved registers. | 1566 // No saved registers. |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 __ Nop(padding_size); | 1774 __ Nop(padding_size); |
1744 } | 1775 } |
1745 } | 1776 } |
1746 } | 1777 } |
1747 | 1778 |
1748 #undef __ | 1779 #undef __ |
1749 | 1780 |
1750 } // namespace internal | 1781 } // namespace internal |
1751 } // namespace compiler | 1782 } // namespace compiler |
1752 } // namespace v8 | 1783 } // namespace v8 |
OLD | NEW |