OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <limits.h> | 5 #include <limits.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #if V8_TARGET_ARCH_MIPS | 10 #if V8_TARGET_ARCH_MIPS |
(...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 | 1784 |
1785 | 1785 |
1786 int Simulator::ReadW(int32_t addr, Instruction* instr) { | 1786 int Simulator::ReadW(int32_t addr, Instruction* instr) { |
1787 if (addr >=0 && addr < 0x400) { | 1787 if (addr >=0 && addr < 0x400) { |
1788 // This has to be a NULL-dereference, drop into debugger. | 1788 // This has to be a NULL-dereference, drop into debugger. |
1789 PrintF("Memory read from bad address: 0x%08x, pc=0x%08x\n", | 1789 PrintF("Memory read from bad address: 0x%08x, pc=0x%08x\n", |
1790 addr, reinterpret_cast<intptr_t>(instr)); | 1790 addr, reinterpret_cast<intptr_t>(instr)); |
1791 MipsDebugger dbg(this); | 1791 MipsDebugger dbg(this); |
1792 dbg.Debug(); | 1792 dbg.Debug(); |
1793 } | 1793 } |
1794 if ((addr & kPointerAlignmentMask) == 0) { | 1794 if ((addr & kPointerAlignmentMask) == 0 || IsMipsArchVariant(kMips32r6)) { |
1795 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); | 1795 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
1796 TraceMemRd(addr, static_cast<int32_t>(*ptr)); | 1796 TraceMemRd(addr, static_cast<int32_t>(*ptr)); |
1797 return *ptr; | 1797 return *ptr; |
1798 } | 1798 } |
1799 PrintF("Unaligned read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1799 PrintF("Unaligned read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1800 addr, | 1800 addr, |
1801 reinterpret_cast<intptr_t>(instr)); | 1801 reinterpret_cast<intptr_t>(instr)); |
1802 MipsDebugger dbg(this); | 1802 MipsDebugger dbg(this); |
1803 dbg.Debug(); | 1803 dbg.Debug(); |
1804 return 0; | 1804 return 0; |
1805 } | 1805 } |
1806 | 1806 |
1807 | 1807 |
1808 void Simulator::WriteW(int32_t addr, int value, Instruction* instr) { | 1808 void Simulator::WriteW(int32_t addr, int value, Instruction* instr) { |
1809 if (addr >= 0 && addr < 0x400) { | 1809 if (addr >= 0 && addr < 0x400) { |
1810 // This has to be a NULL-dereference, drop into debugger. | 1810 // This has to be a NULL-dereference, drop into debugger. |
1811 PrintF("Memory write to bad address: 0x%08x, pc=0x%08x\n", | 1811 PrintF("Memory write to bad address: 0x%08x, pc=0x%08x\n", |
1812 addr, reinterpret_cast<intptr_t>(instr)); | 1812 addr, reinterpret_cast<intptr_t>(instr)); |
1813 MipsDebugger dbg(this); | 1813 MipsDebugger dbg(this); |
1814 dbg.Debug(); | 1814 dbg.Debug(); |
1815 } | 1815 } |
1816 if ((addr & kPointerAlignmentMask) == 0) { | 1816 if ((addr & kPointerAlignmentMask) == 0 || IsMipsArchVariant(kMips32r6)) { |
1817 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); | 1817 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
1818 TraceMemWr(addr, value, WORD); | 1818 TraceMemWr(addr, value, WORD); |
1819 *ptr = value; | 1819 *ptr = value; |
1820 return; | 1820 return; |
1821 } | 1821 } |
1822 PrintF("Unaligned write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1822 PrintF("Unaligned write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1823 addr, | 1823 addr, |
1824 reinterpret_cast<intptr_t>(instr)); | 1824 reinterpret_cast<intptr_t>(instr)); |
1825 MipsDebugger dbg(this); | 1825 MipsDebugger dbg(this); |
1826 dbg.Debug(); | 1826 dbg.Debug(); |
1827 } | 1827 } |
1828 | 1828 |
1829 | 1829 |
1830 double Simulator::ReadD(int32_t addr, Instruction* instr) { | 1830 double Simulator::ReadD(int32_t addr, Instruction* instr) { |
1831 if ((addr & kDoubleAlignmentMask) == 0) { | 1831 if ((addr & kDoubleAlignmentMask) == 0 || IsMipsArchVariant(kMips32r6)) { |
1832 double* ptr = reinterpret_cast<double*>(addr); | 1832 double* ptr = reinterpret_cast<double*>(addr); |
1833 return *ptr; | 1833 return *ptr; |
1834 } | 1834 } |
1835 PrintF("Unaligned (double) read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1835 PrintF("Unaligned (double) read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1836 addr, | 1836 addr, |
1837 reinterpret_cast<intptr_t>(instr)); | 1837 reinterpret_cast<intptr_t>(instr)); |
1838 base::OS::Abort(); | 1838 base::OS::Abort(); |
1839 return 0; | 1839 return 0; |
1840 } | 1840 } |
1841 | 1841 |
1842 | 1842 |
1843 void Simulator::WriteD(int32_t addr, double value, Instruction* instr) { | 1843 void Simulator::WriteD(int32_t addr, double value, Instruction* instr) { |
1844 if ((addr & kDoubleAlignmentMask) == 0) { | 1844 if ((addr & kDoubleAlignmentMask) == 0 || IsMipsArchVariant(kMips32r6)) { |
1845 double* ptr = reinterpret_cast<double*>(addr); | 1845 double* ptr = reinterpret_cast<double*>(addr); |
1846 *ptr = value; | 1846 *ptr = value; |
1847 return; | 1847 return; |
1848 } | 1848 } |
1849 PrintF("Unaligned (double) write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1849 PrintF("Unaligned (double) write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1850 addr, | 1850 addr, |
1851 reinterpret_cast<intptr_t>(instr)); | 1851 reinterpret_cast<intptr_t>(instr)); |
1852 base::OS::Abort(); | 1852 base::OS::Abort(); |
1853 } | 1853 } |
1854 | 1854 |
1855 | 1855 |
1856 uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) { | 1856 uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) { |
1857 if ((addr & 1) == 0) { | 1857 if ((addr & 1) == 0 || IsMipsArchVariant(kMips32r6)) { |
1858 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); | 1858 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
1859 TraceMemRd(addr, static_cast<int32_t>(*ptr)); | 1859 TraceMemRd(addr, static_cast<int32_t>(*ptr)); |
1860 return *ptr; | 1860 return *ptr; |
1861 } | 1861 } |
1862 PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1862 PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1863 addr, | 1863 addr, |
1864 reinterpret_cast<intptr_t>(instr)); | 1864 reinterpret_cast<intptr_t>(instr)); |
1865 base::OS::Abort(); | 1865 base::OS::Abort(); |
1866 return 0; | 1866 return 0; |
1867 } | 1867 } |
1868 | 1868 |
1869 | 1869 |
1870 int16_t Simulator::ReadH(int32_t addr, Instruction* instr) { | 1870 int16_t Simulator::ReadH(int32_t addr, Instruction* instr) { |
1871 if ((addr & 1) == 0) { | 1871 if ((addr & 1) == 0 || IsMipsArchVariant(kMips32r6)) { |
1872 int16_t* ptr = reinterpret_cast<int16_t*>(addr); | 1872 int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
1873 TraceMemRd(addr, static_cast<int32_t>(*ptr)); | 1873 TraceMemRd(addr, static_cast<int32_t>(*ptr)); |
1874 return *ptr; | 1874 return *ptr; |
1875 } | 1875 } |
1876 PrintF("Unaligned signed halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1876 PrintF("Unaligned signed halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1877 addr, | 1877 addr, |
1878 reinterpret_cast<intptr_t>(instr)); | 1878 reinterpret_cast<intptr_t>(instr)); |
1879 base::OS::Abort(); | 1879 base::OS::Abort(); |
1880 return 0; | 1880 return 0; |
1881 } | 1881 } |
1882 | 1882 |
1883 | 1883 |
1884 void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) { | 1884 void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) { |
1885 if ((addr & 1) == 0) { | 1885 if ((addr & 1) == 0 || IsMipsArchVariant(kMips32r6)) { |
1886 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); | 1886 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
1887 TraceMemWr(addr, value, HALF); | 1887 TraceMemWr(addr, value, HALF); |
1888 *ptr = value; | 1888 *ptr = value; |
1889 return; | 1889 return; |
1890 } | 1890 } |
1891 PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1891 PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1892 addr, | 1892 addr, |
1893 reinterpret_cast<intptr_t>(instr)); | 1893 reinterpret_cast<intptr_t>(instr)); |
1894 base::OS::Abort(); | 1894 base::OS::Abort(); |
1895 } | 1895 } |
1896 | 1896 |
1897 | 1897 |
1898 void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) { | 1898 void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) { |
1899 if ((addr & 1) == 0) { | 1899 if ((addr & 1) == 0 || IsMipsArchVariant(kMips32r6)) { |
1900 int16_t* ptr = reinterpret_cast<int16_t*>(addr); | 1900 int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
1901 TraceMemWr(addr, value, HALF); | 1901 TraceMemWr(addr, value, HALF); |
1902 *ptr = value; | 1902 *ptr = value; |
1903 return; | 1903 return; |
1904 } | 1904 } |
1905 PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1905 PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1906 addr, | 1906 addr, |
1907 reinterpret_cast<intptr_t>(instr)); | 1907 reinterpret_cast<intptr_t>(instr)); |
1908 base::OS::Abort(); | 1908 base::OS::Abort(); |
1909 } | 1909 } |
(...skipping 2694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4604 | 4604 |
4605 | 4605 |
4606 #undef UNSUPPORTED | 4606 #undef UNSUPPORTED |
4607 | 4607 |
4608 } // namespace internal | 4608 } // namespace internal |
4609 } // namespace v8 | 4609 } // namespace v8 |
4610 | 4610 |
4611 #endif // USE_SIMULATOR | 4611 #endif // USE_SIMULATOR |
4612 | 4612 |
4613 #endif // V8_TARGET_ARCH_MIPS | 4613 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |