OLD | NEW |
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/compilation-info.h" | 9 #include "src/compilation-info.h" |
10 #include "src/compiler/code-generator-impl.h" | 10 #include "src/compiler/code-generator-impl.h" |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 int deopt_state_id = | 776 int deopt_state_id = |
777 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 777 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
778 Deoptimizer::BailoutType bailout_type = | 778 Deoptimizer::BailoutType bailout_type = |
779 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 779 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
780 CodeGenResult result = AssembleDeoptimizerCall( | 780 CodeGenResult result = AssembleDeoptimizerCall( |
781 deopt_state_id, bailout_type, current_source_position_); | 781 deopt_state_id, bailout_type, current_source_position_); |
782 if (result != kSuccess) return result; | 782 if (result != kSuccess) return result; |
783 break; | 783 break; |
784 } | 784 } |
785 case kArchRet: | 785 case kArchRet: |
786 AssembleReturn(); | 786 AssembleReturn(instr->InputAt(0)); |
787 break; | 787 break; |
788 case kArchStackPointer: | 788 case kArchStackPointer: |
789 __ mov(i.OutputRegister(), masm()->StackPointer()); | 789 __ mov(i.OutputRegister(), masm()->StackPointer()); |
790 break; | 790 break; |
791 case kArchFramePointer: | 791 case kArchFramePointer: |
792 __ mov(i.OutputRegister(), fp); | 792 __ mov(i.OutputRegister(), fp); |
793 break; | 793 break; |
794 case kArchParentFramePointer: | 794 case kArchParentFramePointer: |
795 if (frame_access_state()->has_frame()) { | 795 if (frame_access_state()->has_frame()) { |
796 __ ldr(i.OutputRegister(), MemOperand(fp, 0)); | 796 __ ldr(i.OutputRegister(), MemOperand(fp, 0)); |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 // CPURegList::GetCalleeSaved(): x30 is missing. | 1847 // CPURegList::GetCalleeSaved(): x30 is missing. |
1848 // DCHECK(saves.list() == CPURegList::GetCalleeSaved().list()); | 1848 // DCHECK(saves.list() == CPURegList::GetCalleeSaved().list()); |
1849 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, | 1849 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, |
1850 descriptor->CalleeSavedRegisters()); | 1850 descriptor->CalleeSavedRegisters()); |
1851 saved_count = saves.Count(); | 1851 saved_count = saves.Count(); |
1852 if (saved_count != 0) { | 1852 if (saved_count != 0) { |
1853 __ PushCPURegList(saves); | 1853 __ PushCPURegList(saves); |
1854 } | 1854 } |
1855 } | 1855 } |
1856 | 1856 |
1857 | 1857 void CodeGenerator::AssembleReturn(InstructionOperand* pop) { |
1858 void CodeGenerator::AssembleReturn() { | |
1859 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1858 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1860 | 1859 |
1861 // Restore registers. | 1860 // Restore registers. |
1862 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, | 1861 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, |
1863 descriptor->CalleeSavedRegisters()); | 1862 descriptor->CalleeSavedRegisters()); |
1864 if (saves.Count() != 0) { | 1863 if (saves.Count() != 0) { |
1865 __ PopCPURegList(saves); | 1864 __ PopCPURegList(saves); |
1866 } | 1865 } |
1867 | 1866 |
1868 // Restore fp registers. | 1867 // Restore fp registers. |
1869 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, | 1868 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, |
1870 descriptor->CalleeSavedFPRegisters()); | 1869 descriptor->CalleeSavedFPRegisters()); |
1871 if (saves_fp.Count() != 0) { | 1870 if (saves_fp.Count() != 0) { |
1872 __ PopCPURegList(saves_fp); | 1871 __ PopCPURegList(saves_fp); |
1873 } | 1872 } |
1874 | 1873 |
1875 unwinding_info_writer_.MarkBlockWillExit(); | 1874 unwinding_info_writer_.MarkBlockWillExit(); |
1876 | 1875 |
| 1876 Arm64OperandConverter g(this, nullptr); |
1877 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | 1877 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
1878 if (descriptor->IsCFunctionCall()) { | 1878 if (descriptor->IsCFunctionCall()) { |
1879 AssembleDeconstructFrame(); | 1879 AssembleDeconstructFrame(); |
1880 } else if (frame_access_state()->has_frame()) { | 1880 } else if (frame_access_state()->has_frame()) { |
1881 // Canonicalize JSFunction return sites for now. | 1881 // Canonicalize JSFunction return sites for now unless they have an variable |
1882 if (return_label_.is_bound()) { | 1882 // number of stack slot pops. |
1883 __ B(&return_label_); | 1883 if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) { |
1884 return; | 1884 if (return_label_.is_bound()) { |
| 1885 __ B(&return_label_); |
| 1886 return; |
| 1887 } else { |
| 1888 __ Bind(&return_label_); |
| 1889 AssembleDeconstructFrame(); |
| 1890 if (descriptor->UseNativeStack()) { |
| 1891 pop_count += (pop_count & 1); // align |
| 1892 } |
| 1893 } |
1885 } else { | 1894 } else { |
1886 __ Bind(&return_label_); | |
1887 AssembleDeconstructFrame(); | 1895 AssembleDeconstructFrame(); |
1888 if (descriptor->UseNativeStack()) { | 1896 if (descriptor->UseNativeStack()) { |
1889 pop_count += (pop_count & 1); // align | 1897 pop_count += (pop_count & 1); // align |
1890 } | 1898 } |
1891 } | 1899 } |
1892 } else if (descriptor->UseNativeStack()) { | 1900 } else if (descriptor->UseNativeStack()) { |
1893 pop_count += (pop_count & 1); // align | 1901 pop_count += (pop_count & 1); // align |
1894 } | 1902 } |
1895 __ Drop(pop_count); | 1903 |
| 1904 if (pop->IsImmediate()) { |
| 1905 DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type()); |
| 1906 pop_count += g.ToConstant(pop).ToInt32(); |
| 1907 __ Drop(pop_count); |
| 1908 } else { |
| 1909 Register pop_reg = g.ToRegister(pop); |
| 1910 __ Add(pop_reg, pop_reg, pop_count); |
| 1911 __ Drop(pop_reg); |
| 1912 } |
1896 | 1913 |
1897 if (descriptor->UseNativeStack()) { | 1914 if (descriptor->UseNativeStack()) { |
1898 __ AssertCspAligned(); | 1915 __ AssertCspAligned(); |
1899 } | 1916 } |
1900 __ Ret(); | 1917 __ Ret(); |
1901 } | 1918 } |
1902 | 1919 |
1903 | 1920 |
1904 void CodeGenerator::AssembleMove(InstructionOperand* source, | 1921 void CodeGenerator::AssembleMove(InstructionOperand* source, |
1905 InstructionOperand* destination) { | 1922 InstructionOperand* destination) { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 padding_size -= kInstructionSize; | 2102 padding_size -= kInstructionSize; |
2086 } | 2103 } |
2087 } | 2104 } |
2088 } | 2105 } |
2089 | 2106 |
2090 #undef __ | 2107 #undef __ |
2091 | 2108 |
2092 } // namespace compiler | 2109 } // namespace compiler |
2093 } // namespace internal | 2110 } // namespace internal |
2094 } // namespace v8 | 2111 } // namespace v8 |
OLD | NEW |