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

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

Issue 2446543002: [turbofan] Support variable size argument popping in TF-generated functions (Closed)
Patch Set: Fix tests and arm64 Created 4 years, 1 month 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
« no previous file with comments | « src/code-stubs.cc ('k') | src/compiler/arm64/code-generator-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/arm/macro-assembler-arm.h" 7 #include "src/arm/macro-assembler-arm.h"
8 #include "src/compilation-info.h" 8 #include "src/compilation-info.h"
9 #include "src/compiler/code-generator-impl.h" 9 #include "src/compiler/code-generator-impl.h"
10 #include "src/compiler/gap-resolver.h" 10 #include "src/compiler/gap-resolver.h"
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 int deopt_state_id = 737 int deopt_state_id =
738 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); 738 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore());
739 Deoptimizer::BailoutType bailout_type = 739 Deoptimizer::BailoutType bailout_type =
740 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); 740 Deoptimizer::BailoutType(MiscField::decode(instr->opcode()));
741 CodeGenResult result = AssembleDeoptimizerCall( 741 CodeGenResult result = AssembleDeoptimizerCall(
742 deopt_state_id, bailout_type, current_source_position_); 742 deopt_state_id, bailout_type, current_source_position_);
743 if (result != kSuccess) return result; 743 if (result != kSuccess) return result;
744 break; 744 break;
745 } 745 }
746 case kArchRet: 746 case kArchRet:
747 AssembleReturn(); 747 AssembleReturn(instr->InputAt(0));
748 DCHECK_EQ(LeaveCC, i.OutputSBit()); 748 DCHECK_EQ(LeaveCC, i.OutputSBit());
749 break; 749 break;
750 case kArchStackPointer: 750 case kArchStackPointer:
751 __ mov(i.OutputRegister(), sp); 751 __ mov(i.OutputRegister(), sp);
752 DCHECK_EQ(LeaveCC, i.OutputSBit()); 752 DCHECK_EQ(LeaveCC, i.OutputSBit());
753 break; 753 break;
754 case kArchFramePointer: 754 case kArchFramePointer:
755 __ mov(i.OutputRegister(), fp); 755 __ mov(i.OutputRegister(), fp);
756 DCHECK_EQ(LeaveCC, i.OutputSBit()); 756 DCHECK_EQ(LeaveCC, i.OutputSBit());
757 break; 757 break;
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 } 1730 }
1731 const RegList saves = FLAG_enable_embedded_constant_pool 1731 const RegList saves = FLAG_enable_embedded_constant_pool
1732 ? (descriptor->CalleeSavedRegisters() & ~pp.bit()) 1732 ? (descriptor->CalleeSavedRegisters() & ~pp.bit())
1733 : descriptor->CalleeSavedRegisters(); 1733 : descriptor->CalleeSavedRegisters();
1734 if (saves != 0) { 1734 if (saves != 0) {
1735 // Save callee-saved registers. 1735 // Save callee-saved registers.
1736 __ stm(db_w, sp, saves); 1736 __ stm(db_w, sp, saves);
1737 } 1737 }
1738 } 1738 }
1739 1739
1740 1740 void CodeGenerator::AssembleReturn(InstructionOperand* pop) {
1741 void CodeGenerator::AssembleReturn() {
1742 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1741 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1743 int pop_count = static_cast<int>(descriptor->StackParameterCount()); 1742 int pop_count = static_cast<int>(descriptor->StackParameterCount());
1744 1743
1745 // Restore registers. 1744 // Restore registers.
1746 const RegList saves = FLAG_enable_embedded_constant_pool 1745 const RegList saves = FLAG_enable_embedded_constant_pool
1747 ? (descriptor->CalleeSavedRegisters() & ~pp.bit()) 1746 ? (descriptor->CalleeSavedRegisters() & ~pp.bit())
1748 : descriptor->CalleeSavedRegisters(); 1747 : descriptor->CalleeSavedRegisters();
1749 if (saves != 0) { 1748 if (saves != 0) {
1750 __ ldm(ia_w, sp, saves); 1749 __ ldm(ia_w, sp, saves);
1751 } 1750 }
1752 1751
1753 // Restore FP registers. 1752 // Restore FP registers.
1754 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); 1753 const RegList saves_fp = descriptor->CalleeSavedFPRegisters();
1755 if (saves_fp != 0) { 1754 if (saves_fp != 0) {
1756 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); 1755 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32);
1757 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; 1756 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1;
1758 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); 1757 uint32_t first = base::bits::CountTrailingZeros32(saves_fp);
1759 __ vldm(ia_w, sp, DwVfpRegister::from_code(first), 1758 __ vldm(ia_w, sp, DwVfpRegister::from_code(first),
1760 DwVfpRegister::from_code(last)); 1759 DwVfpRegister::from_code(last));
1761 } 1760 }
1762 1761
1763 unwinding_info_writer_.MarkBlockWillExit(); 1762 unwinding_info_writer_.MarkBlockWillExit();
1764 1763
1764 ArmOperandConverter g(this, nullptr);
1765 if (descriptor->IsCFunctionCall()) { 1765 if (descriptor->IsCFunctionCall()) {
1766 AssembleDeconstructFrame(); 1766 AssembleDeconstructFrame();
1767 } else if (frame_access_state()->has_frame()) { 1767 } else if (frame_access_state()->has_frame()) {
1768 // Canonicalize JSFunction return sites for now. 1768 // Canonicalize JSFunction return sites for now unless they have an variable
1769 if (return_label_.is_bound()) { 1769 // number of stack slot pops.
1770 __ b(&return_label_); 1770 if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) {
1771 return; 1771 if (return_label_.is_bound()) {
1772 __ b(&return_label_);
1773 return;
1774 } else {
1775 __ bind(&return_label_);
1776 AssembleDeconstructFrame();
1777 }
1772 } else { 1778 } else {
1773 __ bind(&return_label_);
1774 AssembleDeconstructFrame(); 1779 AssembleDeconstructFrame();
1775 } 1780 }
1776 } 1781 }
1777 __ Ret(pop_count); 1782
1783 if (pop->IsImmediate()) {
1784 DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type());
1785 pop_count += g.ToConstant(pop).ToInt32();
1786 } else {
1787 __ Drop(g.ToRegister(pop));
1788 }
1789 __ Drop(pop_count);
1790 __ Ret();
1778 } 1791 }
1779 1792
1780 void CodeGenerator::AssembleMove(InstructionOperand* source, 1793 void CodeGenerator::AssembleMove(InstructionOperand* source,
1781 InstructionOperand* destination) { 1794 InstructionOperand* destination) {
1782 ArmOperandConverter g(this, nullptr); 1795 ArmOperandConverter g(this, nullptr);
1783 // Dispatch on the source and destination operand kinds. Not all 1796 // Dispatch on the source and destination operand kinds. Not all
1784 // combinations are possible. 1797 // combinations are possible.
1785 if (source->IsRegister()) { 1798 if (source->IsRegister()) {
1786 DCHECK(destination->IsRegister() || destination->IsStackSlot()); 1799 DCHECK(destination->IsRegister() || destination->IsStackSlot());
1787 Register src = g.ToRegister(source); 1800 Register src = g.ToRegister(source);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 padding_size -= v8::internal::Assembler::kInstrSize; 2049 padding_size -= v8::internal::Assembler::kInstrSize;
2037 } 2050 }
2038 } 2051 }
2039 } 2052 }
2040 2053
2041 #undef __ 2054 #undef __
2042 2055
2043 } // namespace compiler 2056 } // namespace compiler
2044 } // namespace internal 2057 } // namespace internal
2045 } // namespace v8 2058 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/compiler/arm64/code-generator-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698