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

Side by Side Diff: src/compiler/mips/code-generator-mips.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/ast/scopes.h" 5 #include "src/ast/scopes.h"
6 #include "src/compiler/code-generator.h" 6 #include "src/compiler/code-generator.h"
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/compiler/osr.h" 10 #include "src/compiler/osr.h"
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 __ cvt_s_w(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ 470 __ cvt_s_w(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \
471 __ bind(ool->exit()); \ 471 __ bind(ool->exit()); \
472 __ bind(&done); \ 472 __ bind(&done); \
473 } 473 }
474 474
475 void CodeGenerator::AssembleDeconstructFrame() { 475 void CodeGenerator::AssembleDeconstructFrame() {
476 __ mov(sp, fp); 476 __ mov(sp, fp);
477 __ Pop(ra, fp); 477 __ Pop(ra, fp);
478 } 478 }
479 479
480 void CodeGenerator::AssembleSetupStackPointer() {}
481
482 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { 480 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) {
483 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); 481 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta);
484 if (sp_slot_delta > 0) { 482 if (sp_slot_delta > 0) {
485 __ addiu(sp, sp, sp_slot_delta * kPointerSize); 483 __ addiu(sp, sp, sp_slot_delta * kPointerSize);
486 } 484 }
487 frame_access_state()->SetFrameAccessToDefault(); 485 frame_access_state()->SetFrameAccessToDefault();
488 } 486 }
489 487
490 488
491 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { 489 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) {
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 } 1560 }
1563 1561
1564 1562
1565 void CodeGenerator::AssembleDeoptimizerCall( 1563 void CodeGenerator::AssembleDeoptimizerCall(
1566 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { 1564 int deoptimization_id, Deoptimizer::BailoutType bailout_type) {
1567 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( 1565 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry(
1568 isolate(), deoptimization_id, bailout_type); 1566 isolate(), deoptimization_id, bailout_type);
1569 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); 1567 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY);
1570 } 1568 }
1571 1569
1570 void CodeGenerator::FinishFrame(Frame* frame) {
1571 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1572 int stack_shrink_slots = frame->GetSpillSlotCount();
1573 if (info()->is_osr()) {
1574 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
1575 }
1572 1576
1573 void CodeGenerator::AssemblePrologue() { 1577 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1578 if (saves_fpu != 0) {
1579 stack_shrink_slots += frame->AlignSavedCalleeRegisterSlots();
1580 }
1581
1582 if (saves_fpu != 0) {
1583 int count = base::bits::CountPopulation32(saves_fpu);
1584 DCHECK(kNumCalleeSavedFPU == count);
1585 frame->AllocateSavedCalleeRegisterSlots(count *
1586 (kDoubleSize / kPointerSize));
1587 }
1588
1589 const RegList saves = descriptor->CalleeSavedRegisters();
1590 if (saves != 0) {
1591 int count = base::bits::CountPopulation32(saves);
1592 DCHECK(kNumCalleeSaved == count + 1);
1593 frame->AllocateSavedCalleeRegisterSlots(count);
1594 }
1595 frame->set_stack_shrink_slots(stack_shrink_slots);
1596 }
1597
1598 void CodeGenerator::AssembleConstructFrame() {
1574 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1599 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1575 int stack_shrink_slots = frame()->GetSpillSlotCount();
1576 if (frame_access_state()->has_frame()) { 1600 if (frame_access_state()->has_frame()) {
1577 if (descriptor->IsCFunctionCall()) { 1601 if (descriptor->IsCFunctionCall()) {
1578 __ Push(ra, fp); 1602 __ Push(ra, fp);
1579 __ mov(fp, sp); 1603 __ mov(fp, sp);
1580 } else if (descriptor->IsJSFunctionCall()) { 1604 } else if (descriptor->IsJSFunctionCall()) {
1581 __ Prologue(this->info()->GeneratePreagedPrologue()); 1605 __ Prologue(this->info()->GeneratePreagedPrologue());
1582 } else { 1606 } else {
1583 __ StubPrologue(info()->GetOutputStackFrameType()); 1607 __ StubPrologue(info()->GetOutputStackFrameType());
1584 } 1608 }
1585 } 1609 }
1586 1610
1587 if (info()->is_osr()) { 1611 if (info()->is_osr()) {
1588 // TurboFan OSR-compiled functions cannot be entered directly. 1612 // TurboFan OSR-compiled functions cannot be entered directly.
1589 __ Abort(kShouldNotDirectlyEnterOsrFunction); 1613 __ Abort(kShouldNotDirectlyEnterOsrFunction);
1590 1614
1591 // Unoptimized code jumps directly to this entrypoint while the unoptimized 1615 // Unoptimized code jumps directly to this entrypoint while the unoptimized
1592 // frame is still on the stack. Optimized code uses OSR values directly from 1616 // frame is still on the stack. Optimized code uses OSR values directly from
1593 // the unoptimized frame. Thus, all that needs to be done is to allocate the 1617 // the unoptimized frame. Thus, all that needs to be done is to allocate the
1594 // remaining stack slots. 1618 // remaining stack slots.
1595 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); 1619 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
1596 osr_pc_offset_ = __ pc_offset(); 1620 osr_pc_offset_ = __ pc_offset();
1597 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
1598 } 1621 }
1599 1622
1600 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); 1623 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1601 if (saves_fpu != 0) { 1624 if (frame()->stack_shrink_slots() > 0) {
1602 stack_shrink_slots += frame()->AlignSavedCalleeRegisterSlots(); 1625 __ Subu(sp, sp, Operand(frame()->stack_shrink_slots() * kPointerSize));
1603 }
1604 if (stack_shrink_slots > 0) {
1605 __ Subu(sp, sp, Operand(stack_shrink_slots * kPointerSize));
1606 } 1626 }
1607 1627
1608 // Save callee-saved FPU registers. 1628 // Save callee-saved FPU registers.
1609 if (saves_fpu != 0) { 1629 if (saves_fpu != 0) {
1610 __ MultiPushFPU(saves_fpu); 1630 __ MultiPushFPU(saves_fpu);
1611 int count = base::bits::CountPopulation32(saves_fpu);
1612 DCHECK(kNumCalleeSavedFPU == count);
1613 frame()->AllocateSavedCalleeRegisterSlots(count *
1614 (kDoubleSize / kPointerSize));
1615 } 1631 }
1616 1632
1617 const RegList saves = descriptor->CalleeSavedRegisters(); 1633 const RegList saves = descriptor->CalleeSavedRegisters();
1618 if (saves != 0) { 1634 if (saves != 0) {
1619 // Save callee-saved registers. 1635 // Save callee-saved registers.
1620 __ MultiPush(saves); 1636 __ MultiPush(saves);
1621 // kNumCalleeSaved includes the fp register, but the fp register 1637 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1);
1622 // is saved separately in TF.
1623 int count = base::bits::CountPopulation32(saves);
1624 DCHECK(kNumCalleeSaved == count + 1);
1625 frame()->AllocateSavedCalleeRegisterSlots(count);
1626 } 1638 }
1627 } 1639 }
1628 1640
1629 1641
1630 void CodeGenerator::AssembleReturn() { 1642 void CodeGenerator::AssembleReturn() {
1631 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1643 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1632 int pop_count = static_cast<int>(descriptor->StackParameterCount()); 1644 int pop_count = static_cast<int>(descriptor->StackParameterCount());
1633 1645
1634 // Restore GP registers. 1646 // Restore GP registers.
1635 const RegList saves = descriptor->CalleeSavedRegisters(); 1647 const RegList saves = descriptor->CalleeSavedRegisters();
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 padding_size -= v8::internal::Assembler::kInstrSize; 1881 padding_size -= v8::internal::Assembler::kInstrSize;
1870 } 1882 }
1871 } 1883 }
1872 } 1884 }
1873 1885
1874 #undef __ 1886 #undef __
1875 1887
1876 } // namespace compiler 1888 } // namespace compiler
1877 } // namespace internal 1889 } // namespace internal
1878 } // namespace v8 1890 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698