Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/compiler/arm64/code-generator-arm64.cc

Issue 1843143002: [turbofan] CodeGenerator: Frame setup refactoring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/arm64/frames-arm64.h" 7 #include "src/arm64/frames-arm64.h"
8 #include "src/arm64/macro-assembler-arm64.h" 8 #include "src/arm64/macro-assembler-arm64.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/compiler/code-generator-impl.h" 10 #include "src/compiler/code-generator-impl.h"
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 } 1508 }
1509 1509
1510 1510
1511 void CodeGenerator::AssembleDeoptimizerCall( 1511 void CodeGenerator::AssembleDeoptimizerCall(
1512 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { 1512 int deoptimization_id, Deoptimizer::BailoutType bailout_type) {
1513 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( 1513 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry(
1514 isolate(), deoptimization_id, bailout_type); 1514 isolate(), deoptimization_id, bailout_type);
1515 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); 1515 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY);
1516 } 1516 }
1517 1517
1518 void CodeGenerator::AssembleSetupStackPointer() { 1518 void CodeGenerator::FinishFrame(Frame* frame) {
1519 const CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1519 frame->AlignFrame(16);
1520 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1521
1520 if (descriptor->UseNativeStack() || descriptor->IsCFunctionCall()) { 1522 if (descriptor->UseNativeStack() || descriptor->IsCFunctionCall()) {
1521 __ SetStackPointer(csp); 1523 __ SetStackPointer(csp);
1522 } else { 1524 } else {
1523 __ SetStackPointer(jssp); 1525 __ SetStackPointer(jssp);
1524 } 1526 }
1527
1528 // Save FP registers.
1529 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits,
1530 descriptor->CalleeSavedFPRegisters());
1531 int saved_count = saves_fp.Count();
1532 if (saved_count != 0) {
1533 DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedFP().list());
1534 frame->AllocateSavedCalleeRegisterSlots(saved_count *
1535 (kDoubleSize / kPointerSize));
1536 }
1537
1538 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits,
1539 descriptor->CalleeSavedRegisters());
1540 saved_count = saves.Count();
1541 if (saved_count != 0) {
1542 frame->AllocateSavedCalleeRegisterSlots(saved_count);
1543 }
1525 } 1544 }
1526 1545
1527 void CodeGenerator::AssemblePrologue() { 1546 void CodeGenerator::AssembleConstructFrame() {
1528 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1547 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1529 if (descriptor->UseNativeStack()) { 1548 if (descriptor->UseNativeStack()) {
1530 __ AssertCspAligned(); 1549 __ AssertCspAligned();
1531 } 1550 }
1532 1551
1533 int stack_shrink_slots = frame()->GetSpillSlotCount();
1534 if (frame_access_state()->has_frame()) { 1552 if (frame_access_state()->has_frame()) {
1535 if (descriptor->IsJSFunctionCall()) { 1553 if (descriptor->IsJSFunctionCall()) {
1536 DCHECK(!descriptor->UseNativeStack()); 1554 DCHECK(!descriptor->UseNativeStack());
1537 __ Prologue(this->info()->GeneratePreagedPrologue()); 1555 __ Prologue(this->info()->GeneratePreagedPrologue());
1538 } else { 1556 } else {
1539 if (descriptor->IsCFunctionCall()) { 1557 if (descriptor->IsCFunctionCall()) {
1540 __ Push(lr, fp); 1558 __ Push(lr, fp);
1541 __ Mov(fp, masm_.StackPointer()); 1559 __ Mov(fp, masm_.StackPointer());
1542 __ Claim(stack_shrink_slots); 1560 __ Claim(frame()->GetSpillSlotCount());
1543 } else { 1561 } else {
1544 __ StubPrologue(info()->GetOutputStackFrameType(), 1562 __ StubPrologue(info()->GetOutputStackFrameType(),
1545 frame()->GetTotalFrameSlotCount()); 1563 frame()->GetTotalFrameSlotCount());
1546 } 1564 }
1547 } 1565 }
1548 } 1566 }
1549 1567
1568 int shrink_slots = frame()->GetSpillSlotCount();
1569
1550 if (info()->is_osr()) { 1570 if (info()->is_osr()) {
1551 // TurboFan OSR-compiled functions cannot be entered directly. 1571 // TurboFan OSR-compiled functions cannot be entered directly.
1552 __ Abort(kShouldNotDirectlyEnterOsrFunction); 1572 __ Abort(kShouldNotDirectlyEnterOsrFunction);
1553 1573
1554 // Unoptimized code jumps directly to this entrypoint while the unoptimized 1574 // Unoptimized code jumps directly to this entrypoint while the unoptimized
1555 // frame is still on the stack. Optimized code uses OSR values directly from 1575 // frame is still on the stack. Optimized code uses OSR values directly from
1556 // the unoptimized frame. Thus, all that needs to be done is to allocate the 1576 // the unoptimized frame. Thus, all that needs to be done is to allocate the
1557 // remaining stack slots. 1577 // remaining stack slots.
1558 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); 1578 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
1559 osr_pc_offset_ = __ pc_offset(); 1579 osr_pc_offset_ = __ pc_offset();
1560 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); 1580 shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
1561 } 1581 }
1562 1582
1563 if (descriptor->IsJSFunctionCall()) { 1583 if (descriptor->IsJSFunctionCall()) {
1564 __ Claim(stack_shrink_slots); 1584 __ Claim(shrink_slots);
1565 } 1585 }
1566 1586
1567 // Save FP registers. 1587 // Save FP registers.
1568 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, 1588 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits,
1569 descriptor->CalleeSavedFPRegisters()); 1589 descriptor->CalleeSavedFPRegisters());
1570 int saved_count = saves_fp.Count(); 1590 int saved_count = saves_fp.Count();
1571 if (saved_count != 0) { 1591 if (saved_count != 0) {
1572 DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedFP().list()); 1592 DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedFP().list());
1573 __ PushCPURegList(saves_fp); 1593 __ PushCPURegList(saves_fp);
1574 frame()->AllocateSavedCalleeRegisterSlots(saved_count *
1575 (kDoubleSize / kPointerSize));
1576 } 1594 }
1577 // Save registers. 1595 // Save registers.
1578 // TODO(palfia): TF save list is not in sync with 1596 // TODO(palfia): TF save list is not in sync with
1579 // CPURegList::GetCalleeSaved(): x30 is missing. 1597 // CPURegList::GetCalleeSaved(): x30 is missing.
1580 // DCHECK(saves.list() == CPURegList::GetCalleeSaved().list()); 1598 // DCHECK(saves.list() == CPURegList::GetCalleeSaved().list());
1581 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, 1599 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits,
1582 descriptor->CalleeSavedRegisters()); 1600 descriptor->CalleeSavedRegisters());
1583 saved_count = saves.Count(); 1601 saved_count = saves.Count();
1584 if (saved_count != 0) { 1602 if (saved_count != 0) {
1585 __ PushCPURegList(saves); 1603 __ PushCPURegList(saves);
1586 frame()->AllocateSavedCalleeRegisterSlots(saved_count);
1587 } 1604 }
1588 } 1605 }
1589 1606
1590 1607
1591 void CodeGenerator::AssembleReturn() { 1608 void CodeGenerator::AssembleReturn() {
1592 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1609 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1593 1610
1594 // Restore registers. 1611 // Restore registers.
1595 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, 1612 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits,
1596 descriptor->CalleeSavedRegisters()); 1613 descriptor->CalleeSavedRegisters());
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 padding_size -= kInstructionSize; 1831 padding_size -= kInstructionSize;
1815 } 1832 }
1816 } 1833 }
1817 } 1834 }
1818 1835
1819 #undef __ 1836 #undef __
1820 1837
1821 } // namespace compiler 1838 } // namespace compiler
1822 } // namespace internal 1839 } // namespace internal
1823 } // namespace v8 1840 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698