OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ | 5 #ifndef V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ |
6 #define V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ | 6 #define V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/globals.h" | 9 #include "src/globals.h" |
10 #include "src/mips/assembler-mips.h" | 10 #include "src/mips/assembler-mips.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 201 } |
202 | 202 |
203 bool IsNear(Label* L, Condition cond, int rs_reg); | 203 bool IsNear(Label* L, Condition cond, int rs_reg); |
204 | 204 |
205 void Branch(Label* L, | 205 void Branch(Label* L, |
206 Condition cond, | 206 Condition cond, |
207 Register rs, | 207 Register rs, |
208 Heap::RootListIndex index, | 208 Heap::RootListIndex index, |
209 BranchDelaySlot bdslot = PROTECT); | 209 BranchDelaySlot bdslot = PROTECT); |
210 | 210 |
| 211 // Number of instructions needed for calculation of switch table entry address |
| 212 #ifdef _MIPS_ARCH_MIPS32R6 |
| 213 static const int kSwitchTablePrologueSize = 5; |
| 214 #else |
| 215 static const int kSwitchTablePrologueSize = 10; |
| 216 #endif |
211 // GetLabelFunction must be lambda '[](size_t index) -> Label*' or a | 217 // GetLabelFunction must be lambda '[](size_t index) -> Label*' or a |
212 // functor/function with 'Label *func(size_t index)' declaration. | 218 // functor/function with 'Label *func(size_t index)' declaration. |
213 template <typename Func> | 219 template <typename Func> |
214 void GenerateSwitchTable(Register index, size_t case_count, | 220 void GenerateSwitchTable(Register index, size_t case_count, |
215 Func GetLabelFunction); | 221 Func GetLabelFunction); |
216 #undef COND_ARGS | 222 #undef COND_ARGS |
217 | 223 |
218 // Emit code that loads |parameter_index|'th parameter from the stack to | 224 // Emit code that loads |parameter_index|'th parameter from the stack to |
219 // the register according to the CallInterfaceDescriptor definition. | 225 // the register according to the CallInterfaceDescriptor definition. |
220 // |sp_to_caller_sp_offset_in_words| specifies the number of words pushed | 226 // |sp_to_caller_sp_offset_in_words| specifies the number of words pushed |
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 byte* address_; // The address of the code being patched. | 1817 byte* address_; // The address of the code being patched. |
1812 int size_; // Number of bytes of the expected patch size. | 1818 int size_; // Number of bytes of the expected patch size. |
1813 MacroAssembler masm_; // Macro assembler used to generate the code. | 1819 MacroAssembler masm_; // Macro assembler used to generate the code. |
1814 FlushICache flush_cache_; // Whether to flush the I cache after patching. | 1820 FlushICache flush_cache_; // Whether to flush the I cache after patching. |
1815 }; | 1821 }; |
1816 | 1822 |
1817 template <typename Func> | 1823 template <typename Func> |
1818 void MacroAssembler::GenerateSwitchTable(Register index, size_t case_count, | 1824 void MacroAssembler::GenerateSwitchTable(Register index, size_t case_count, |
1819 Func GetLabelFunction) { | 1825 Func GetLabelFunction) { |
1820 if (kArchVariant >= kMips32r6) { | 1826 if (kArchVariant >= kMips32r6) { |
1821 BlockTrampolinePoolFor(case_count + 5); | 1827 BlockTrampolinePoolFor(case_count + kSwitchTablePrologueSize); |
1822 addiupc(at, 5); | 1828 addiupc(at, 5); |
1823 Lsa(at, at, index, kPointerSizeLog2); | 1829 Lsa(at, at, index, kPointerSizeLog2); |
1824 lw(at, MemOperand(at)); | 1830 lw(at, MemOperand(at)); |
1825 } else { | 1831 } else { |
1826 Label here; | 1832 Label here; |
1827 BlockTrampolinePoolFor(case_count + 10); | 1833 BlockTrampolinePoolFor(case_count + kSwitchTablePrologueSize); |
1828 push(ra); | 1834 push(ra); |
1829 bal(&here); | 1835 bal(&here); |
1830 sll(at, index, kPointerSizeLog2); // Branch delay slot. | 1836 sll(at, index, kPointerSizeLog2); // Branch delay slot. |
1831 bind(&here); | 1837 bind(&here); |
1832 addu(at, at, ra); | 1838 addu(at, at, ra); |
1833 pop(ra); | 1839 pop(ra); |
1834 lw(at, MemOperand(at, 6 * v8::internal::Assembler::kInstrSize)); | 1840 lw(at, MemOperand(at, 6 * v8::internal::Assembler::kInstrSize)); |
1835 } | 1841 } |
1836 jr(at); | 1842 jr(at); |
1837 nop(); // Branch delay slot nop. | 1843 nop(); // Branch delay slot nop. |
1838 for (size_t index = 0; index < case_count; ++index) { | 1844 for (size_t index = 0; index < case_count; ++index) { |
1839 dd(GetLabelFunction(index)); | 1845 dd(GetLabelFunction(index)); |
1840 } | 1846 } |
1841 } | 1847 } |
1842 | 1848 |
1843 #define ACCESS_MASM(masm) masm-> | 1849 #define ACCESS_MASM(masm) masm-> |
1844 | 1850 |
1845 } // namespace internal | 1851 } // namespace internal |
1846 } // namespace v8 | 1852 } // namespace v8 |
1847 | 1853 |
1848 #endif // V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ | 1854 #endif // V8_MIPS_MACRO_ASSEMBLER_MIPS_H_ |
OLD | NEW |