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

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 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 } 1496 }
1497 1497
1498 1498
1499 void CodeGenerator::AssembleDeoptimizerCall( 1499 void CodeGenerator::AssembleDeoptimizerCall(
1500 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { 1500 int deoptimization_id, Deoptimizer::BailoutType bailout_type) {
1501 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( 1501 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry(
1502 isolate(), deoptimization_id, bailout_type); 1502 isolate(), deoptimization_id, bailout_type);
1503 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); 1503 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY);
1504 } 1504 }
1505 1505
1506 void CodeGenerator::AssembleSetupStackPointer() { 1506 void CodeGenerator::FinishFrame(Frame* frame) {
1507 const CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1507 frame->AlignFrame(16);
1508 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1509
1508 if (descriptor->UseNativeStack() || descriptor->IsCFunctionCall()) { 1510 if (descriptor->UseNativeStack() || descriptor->IsCFunctionCall()) {
1509 __ SetStackPointer(csp); 1511 __ SetStackPointer(csp);
1510 } else { 1512 } else {
1511 __ SetStackPointer(jssp); 1513 __ SetStackPointer(jssp);
1512 } 1514 }
1515
1516 int stack_shrink_slots = frame->GetSpillSlotCount();
1517
1518 if (info()->is_osr()) {
1519 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
1520 }
1521
1522 // Save FP registers.
1523 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits,
1524 descriptor->CalleeSavedFPRegisters());
1525 int saved_count = saves_fp.Count();
1526 if (saved_count != 0) {
1527 DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedFP().list());
1528 frame->AllocateSavedCalleeRegisterSlots(saved_count *
1529 (kDoubleSize / kPointerSize));
1530 }
1531
1532 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits,
1533 descriptor->CalleeSavedRegisters());
1534 saved_count = saves.Count();
1535 if (saved_count != 0) {
1536 frame->AllocateSavedCalleeRegisterSlots(saved_count);
1537 }
1538 frame->set_stack_shrink_slots(stack_shrink_slots);
1513 } 1539 }
1514 1540
1515 void CodeGenerator::AssemblePrologue() { 1541 void CodeGenerator::AssembleConstructFrame() {
1516 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1542 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1517 if (descriptor->UseNativeStack()) { 1543 if (descriptor->UseNativeStack()) {
1518 __ AssertCspAligned(); 1544 __ AssertCspAligned();
1519 } 1545 }
1520 1546
1521 int stack_shrink_slots = frame()->GetSpillSlotCount();
1522 if (frame_access_state()->has_frame()) { 1547 if (frame_access_state()->has_frame()) {
1523 if (descriptor->IsJSFunctionCall()) { 1548 if (descriptor->IsJSFunctionCall()) {
1524 DCHECK(!descriptor->UseNativeStack()); 1549 DCHECK(!descriptor->UseNativeStack());
1525 __ Prologue(this->info()->GeneratePreagedPrologue()); 1550 __ Prologue(this->info()->GeneratePreagedPrologue());
1526 } else { 1551 } else {
1527 if (descriptor->IsCFunctionCall()) { 1552 if (descriptor->IsCFunctionCall()) {
1528 __ Push(lr, fp); 1553 __ Push(lr, fp);
1529 __ Mov(fp, masm_.StackPointer()); 1554 __ Mov(fp, masm_.StackPointer());
1530 __ Claim(stack_shrink_slots); 1555 __ Claim(frame()->stack_shrink_slots());
1531 } else { 1556 } else {
1532 __ StubPrologue(info()->GetOutputStackFrameType(), 1557 __ StubPrologue(info()->GetOutputStackFrameType(),
1533 frame()->GetTotalFrameSlotCount()); 1558 frame()->GetTotalFrameSlotCount());
1534 } 1559 }
1535 } 1560 }
1536 } 1561 }
1537 1562
1538 if (info()->is_osr()) { 1563 if (info()->is_osr()) {
1539 // TurboFan OSR-compiled functions cannot be entered directly. 1564 // TurboFan OSR-compiled functions cannot be entered directly.
1540 __ Abort(kShouldNotDirectlyEnterOsrFunction); 1565 __ Abort(kShouldNotDirectlyEnterOsrFunction);
1541 1566
1542 // Unoptimized code jumps directly to this entrypoint while the unoptimized 1567 // Unoptimized code jumps directly to this entrypoint while the unoptimized
1543 // frame is still on the stack. Optimized code uses OSR values directly from 1568 // frame is still on the stack. Optimized code uses OSR values directly from
1544 // the unoptimized frame. Thus, all that needs to be done is to allocate the 1569 // the unoptimized frame. Thus, all that needs to be done is to allocate the
1545 // remaining stack slots. 1570 // remaining stack slots.
1546 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); 1571 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
1547 osr_pc_offset_ = __ pc_offset(); 1572 osr_pc_offset_ = __ pc_offset();
1548 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
1549 } 1573 }
1550 1574
1551 if (descriptor->IsJSFunctionCall()) { 1575 if (descriptor->IsJSFunctionCall()) {
1552 __ Claim(stack_shrink_slots); 1576 __ Claim(frame()->stack_shrink_slots());
1553 } 1577 }
1554 1578
1555 // Save FP registers. 1579 // Save FP registers.
1556 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, 1580 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits,
1557 descriptor->CalleeSavedFPRegisters()); 1581 descriptor->CalleeSavedFPRegisters());
1558 int saved_count = saves_fp.Count(); 1582 int saved_count = saves_fp.Count();
1559 if (saved_count != 0) { 1583 if (saved_count != 0) {
1560 DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedFP().list()); 1584 DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedFP().list());
1561 __ PushCPURegList(saves_fp); 1585 __ PushCPURegList(saves_fp);
1562 frame()->AllocateSavedCalleeRegisterSlots(saved_count *
1563 (kDoubleSize / kPointerSize));
1564 } 1586 }
1565 // Save registers. 1587 // Save registers.
1566 // TODO(palfia): TF save list is not in sync with 1588 // TODO(palfia): TF save list is not in sync with
1567 // CPURegList::GetCalleeSaved(): x30 is missing. 1589 // CPURegList::GetCalleeSaved(): x30 is missing.
1568 // DCHECK(saves.list() == CPURegList::GetCalleeSaved().list()); 1590 // DCHECK(saves.list() == CPURegList::GetCalleeSaved().list());
1569 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, 1591 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits,
1570 descriptor->CalleeSavedRegisters()); 1592 descriptor->CalleeSavedRegisters());
1571 saved_count = saves.Count(); 1593 saved_count = saves.Count();
1572 if (saved_count != 0) { 1594 if (saved_count != 0) {
1573 __ PushCPURegList(saves); 1595 __ PushCPURegList(saves);
1574 frame()->AllocateSavedCalleeRegisterSlots(saved_count);
1575 } 1596 }
1576 } 1597 }
1577 1598
1578 1599
1579 void CodeGenerator::AssembleReturn() { 1600 void CodeGenerator::AssembleReturn() {
1580 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1601 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1581 1602
1582 // Restore registers. 1603 // Restore registers.
1583 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, 1604 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits,
1584 descriptor->CalleeSavedRegisters()); 1605 descriptor->CalleeSavedRegisters());
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 padding_size -= kInstructionSize; 1823 padding_size -= kInstructionSize;
1803 } 1824 }
1804 } 1825 }
1805 } 1826 }
1806 1827
1807 #undef __ 1828 #undef __
1808 1829
1809 } // namespace compiler 1830 } // namespace compiler
1810 } // namespace internal 1831 } // namespace internal
1811 } // namespace v8 1832 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698