| 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(instr->InputAt(0)); | 786 AssembleReturn(); |
| 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 void CodeGenerator::AssembleReturn(InstructionOperand* pop) { | 1857 |
| 1858 void CodeGenerator::AssembleReturn() { |
| 1858 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1859 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| 1859 | 1860 |
| 1860 // Restore registers. | 1861 // Restore registers. |
| 1861 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, | 1862 CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, |
| 1862 descriptor->CalleeSavedRegisters()); | 1863 descriptor->CalleeSavedRegisters()); |
| 1863 if (saves.Count() != 0) { | 1864 if (saves.Count() != 0) { |
| 1864 __ PopCPURegList(saves); | 1865 __ PopCPURegList(saves); |
| 1865 } | 1866 } |
| 1866 | 1867 |
| 1867 // Restore fp registers. | 1868 // Restore fp registers. |
| 1868 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, | 1869 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, |
| 1869 descriptor->CalleeSavedFPRegisters()); | 1870 descriptor->CalleeSavedFPRegisters()); |
| 1870 if (saves_fp.Count() != 0) { | 1871 if (saves_fp.Count() != 0) { |
| 1871 __ PopCPURegList(saves_fp); | 1872 __ PopCPURegList(saves_fp); |
| 1872 } | 1873 } |
| 1873 | 1874 |
| 1874 unwinding_info_writer_.MarkBlockWillExit(); | 1875 unwinding_info_writer_.MarkBlockWillExit(); |
| 1875 | 1876 |
| 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 unless they have an variable | 1881 // Canonicalize JSFunction return sites for now. |
| 1882 // number of stack slot pops. | 1882 if (return_label_.is_bound()) { |
| 1883 if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) { | 1883 __ B(&return_label_); |
| 1884 if (return_label_.is_bound()) { | 1884 return; |
| 1885 __ B(&return_label_); | 1885 } else { |
| 1886 return; | 1886 __ Bind(&return_label_); |
| 1887 } else { | 1887 AssembleDeconstructFrame(); |
| 1888 __ Bind(&return_label_); | 1888 if (descriptor->UseNativeStack()) { |
| 1889 AssembleDeconstructFrame(); | 1889 pop_count += (pop_count & 1); // align |
| 1890 if (descriptor->UseNativeStack()) { | |
| 1891 pop_count += (pop_count & 1); // align | |
| 1892 } | |
| 1893 } | 1890 } |
| 1894 } | 1891 } |
| 1895 } else if (descriptor->UseNativeStack()) { | 1892 } else if (descriptor->UseNativeStack()) { |
| 1896 pop_count += (pop_count & 1); // align | 1893 pop_count += (pop_count & 1); // align |
| 1897 } | 1894 } |
| 1898 | |
| 1899 if (pop->IsImmediate()) { | |
| 1900 DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type()); | |
| 1901 pop_count += g.ToConstant(pop).ToInt32(); | |
| 1902 } else { | |
| 1903 __ Drop(g.ToRegister(pop)); | |
| 1904 } | |
| 1905 __ Drop(pop_count); | 1895 __ Drop(pop_count); |
| 1906 | 1896 |
| 1907 if (descriptor->UseNativeStack()) { | 1897 if (descriptor->UseNativeStack()) { |
| 1908 __ AssertCspAligned(); | 1898 __ AssertCspAligned(); |
| 1909 } | 1899 } |
| 1910 __ Ret(); | 1900 __ Ret(); |
| 1911 } | 1901 } |
| 1912 | 1902 |
| 1913 | 1903 |
| 1914 void CodeGenerator::AssembleMove(InstructionOperand* source, | 1904 void CodeGenerator::AssembleMove(InstructionOperand* source, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 padding_size -= kInstructionSize; | 2085 padding_size -= kInstructionSize; |
| 2096 } | 2086 } |
| 2097 } | 2087 } |
| 2098 } | 2088 } |
| 2099 | 2089 |
| 2100 #undef __ | 2090 #undef __ |
| 2101 | 2091 |
| 2102 } // namespace compiler | 2092 } // namespace compiler |
| 2103 } // namespace internal | 2093 } // namespace internal |
| 2104 } // namespace v8 | 2094 } // namespace v8 |
| OLD | NEW |