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

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 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 } 1618 }
1621 1619
1622 1620
1623 void CodeGenerator::AssembleDeoptimizerCall( 1621 void CodeGenerator::AssembleDeoptimizerCall(
1624 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { 1622 int deoptimization_id, Deoptimizer::BailoutType bailout_type) {
1625 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( 1623 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry(
1626 isolate(), deoptimization_id, bailout_type); 1624 isolate(), deoptimization_id, bailout_type);
1627 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); 1625 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY);
1628 } 1626 }
1629 1627
1628 void CodeGenerator::FinishFrame(Frame* frame) {
1629 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1630 1630
1631 void CodeGenerator::AssemblePrologue() { 1631 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1632 if (saves_fpu != 0) {
1633 frame->AlignSavedCalleeRegisterSlots();
1634 }
1635
1636 if (saves_fpu != 0) {
1637 int count = base::bits::CountPopulation32(saves_fpu);
1638 DCHECK(kNumCalleeSavedFPU == count);
1639 frame->AllocateSavedCalleeRegisterSlots(count *
1640 (kDoubleSize / kPointerSize));
1641 }
1642
1643 const RegList saves = descriptor->CalleeSavedRegisters();
1644 if (saves != 0) {
1645 int count = base::bits::CountPopulation32(saves);
1646 DCHECK(kNumCalleeSaved == count + 1);
1647 frame->AllocateSavedCalleeRegisterSlots(count);
1648 }
1649 }
1650
1651 void CodeGenerator::AssembleConstructFrame() {
1632 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1652 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1633 int stack_shrink_slots = frame()->GetSpillSlotCount();
1634 if (frame_access_state()->has_frame()) { 1653 if (frame_access_state()->has_frame()) {
1635 if (descriptor->IsCFunctionCall()) { 1654 if (descriptor->IsCFunctionCall()) {
1636 __ Push(ra, fp); 1655 __ Push(ra, fp);
1637 __ mov(fp, sp); 1656 __ mov(fp, sp);
1638 } else if (descriptor->IsJSFunctionCall()) { 1657 } else if (descriptor->IsJSFunctionCall()) {
1639 __ Prologue(this->info()->GeneratePreagedPrologue()); 1658 __ Prologue(this->info()->GeneratePreagedPrologue());
1640 } else { 1659 } else {
1641 __ StubPrologue(info()->GetOutputStackFrameType()); 1660 __ StubPrologue(info()->GetOutputStackFrameType());
1642 } 1661 }
1643 } 1662 }
1644 1663
1664 int shrink_slots = frame()->GetSpillSlotCount();
1665
1645 if (info()->is_osr()) { 1666 if (info()->is_osr()) {
1646 // TurboFan OSR-compiled functions cannot be entered directly. 1667 // TurboFan OSR-compiled functions cannot be entered directly.
1647 __ Abort(kShouldNotDirectlyEnterOsrFunction); 1668 __ Abort(kShouldNotDirectlyEnterOsrFunction);
1648 1669
1649 // Unoptimized code jumps directly to this entrypoint while the unoptimized 1670 // Unoptimized code jumps directly to this entrypoint while the unoptimized
1650 // frame is still on the stack. Optimized code uses OSR values directly from 1671 // frame is still on the stack. Optimized code uses OSR values directly from
1651 // the unoptimized frame. Thus, all that needs to be done is to allocate the 1672 // the unoptimized frame. Thus, all that needs to be done is to allocate the
1652 // remaining stack slots. 1673 // remaining stack slots.
1653 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); 1674 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
1654 osr_pc_offset_ = __ pc_offset(); 1675 osr_pc_offset_ = __ pc_offset();
1655 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); 1676 shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
1656 } 1677 }
1657 1678
1658 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); 1679 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
1659 if (saves_fpu != 0) { 1680 if (shrink_slots > 0) {
1660 stack_shrink_slots += frame()->AlignSavedCalleeRegisterSlots(); 1681 __ Subu(sp, sp, Operand(shrink_slots * kPointerSize));
1661 }
1662 if (stack_shrink_slots > 0) {
1663 __ Subu(sp, sp, Operand(stack_shrink_slots * kPointerSize));
1664 } 1682 }
1665 1683
1666 // Save callee-saved FPU registers. 1684 // Save callee-saved FPU registers.
1667 if (saves_fpu != 0) { 1685 if (saves_fpu != 0) {
1668 __ MultiPushFPU(saves_fpu); 1686 __ MultiPushFPU(saves_fpu);
1669 int count = base::bits::CountPopulation32(saves_fpu);
1670 DCHECK(kNumCalleeSavedFPU == count);
1671 frame()->AllocateSavedCalleeRegisterSlots(count *
1672 (kDoubleSize / kPointerSize));
1673 } 1687 }
1674 1688
1675 const RegList saves = descriptor->CalleeSavedRegisters(); 1689 const RegList saves = descriptor->CalleeSavedRegisters();
1676 if (saves != 0) { 1690 if (saves != 0) {
1677 // Save callee-saved registers. 1691 // Save callee-saved registers.
1678 __ MultiPush(saves); 1692 __ MultiPush(saves);
1679 // kNumCalleeSaved includes the fp register, but the fp register 1693 DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1);
1680 // is saved separately in TF.
1681 int count = base::bits::CountPopulation32(saves);
1682 DCHECK(kNumCalleeSaved == count + 1);
1683 frame()->AllocateSavedCalleeRegisterSlots(count);
1684 } 1694 }
1685 } 1695 }
1686 1696
1687 1697
1688 void CodeGenerator::AssembleReturn() { 1698 void CodeGenerator::AssembleReturn() {
1689 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1699 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1690 int pop_count = static_cast<int>(descriptor->StackParameterCount()); 1700 int pop_count = static_cast<int>(descriptor->StackParameterCount());
1691 1701
1692 // Restore GP registers. 1702 // Restore GP registers.
1693 const RegList saves = descriptor->CalleeSavedRegisters(); 1703 const RegList saves = descriptor->CalleeSavedRegisters();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 padding_size -= v8::internal::Assembler::kInstrSize; 1941 padding_size -= v8::internal::Assembler::kInstrSize;
1932 } 1942 }
1933 } 1943 }
1934 } 1944 }
1935 1945
1936 #undef __ 1946 #undef __
1937 1947
1938 } // namespace compiler 1948 } // namespace compiler
1939 } // namespace internal 1949 } // namespace internal
1940 } // namespace v8 1950 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698