| 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 #include "src/v8.h" | 10 #include "src/v8.h" |
| (...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 | 1613 |
| 1614 | 1614 |
| 1615 // The MIPS cannot do unaligned reads and writes. On some MIPS platforms an | 1615 // The MIPS cannot do unaligned reads and writes. On some MIPS platforms an |
| 1616 // interrupt is caused. On others it does a funky rotation thing. For now we | 1616 // interrupt is caused. On others it does a funky rotation thing. For now we |
| 1617 // simply disallow unaligned reads, but at some point we may want to move to | 1617 // simply disallow unaligned reads, but at some point we may want to move to |
| 1618 // emulating the rotate behaviour. Note that simulator runs have the runtime | 1618 // emulating the rotate behaviour. Note that simulator runs have the runtime |
| 1619 // system running directly on the host system and only generated code is | 1619 // system running directly on the host system and only generated code is |
| 1620 // executed in the simulator. Since the host is typically IA32 we will not | 1620 // executed in the simulator. Since the host is typically IA32 we will not |
| 1621 // get the correct MIPS-like behaviour on unaligned accesses. | 1621 // get the correct MIPS-like behaviour on unaligned accesses. |
| 1622 | 1622 |
| 1623 void Simulator::TraceRegWr(int32_t value) { |
| 1624 if (::v8::internal::FLAG_trace_sim) { |
| 1625 SNPrintF(trace_buf_, "%08x", value); |
| 1626 } |
| 1627 } |
| 1628 |
| 1629 |
| 1630 // TODO(plind): consider making icount_ printing a flag option. |
| 1631 void Simulator::TraceMemRd(int32_t addr, int32_t value) { |
| 1632 if (::v8::internal::FLAG_trace_sim) { |
| 1633 SNPrintF(trace_buf_, "%08x <-- [%08x] (%d)", value, addr, icount_); |
| 1634 } |
| 1635 } |
| 1636 |
| 1637 |
| 1638 void Simulator::TraceMemWr(int32_t addr, int32_t value, TraceType t) { |
| 1639 if (::v8::internal::FLAG_trace_sim) { |
| 1640 switch (t) { |
| 1641 case BYTE: |
| 1642 SNPrintF(trace_buf_, " %02x --> [%08x]", |
| 1643 static_cast<int8_t>(value), addr); |
| 1644 break; |
| 1645 case HALF: |
| 1646 SNPrintF(trace_buf_, " %04x --> [%08x]", static_cast<int16_t>(value), |
| 1647 addr); |
| 1648 break; |
| 1649 case WORD: |
| 1650 SNPrintF(trace_buf_, "%08x --> [%08x]", value, addr); |
| 1651 break; |
| 1652 } |
| 1653 } |
| 1654 } |
| 1655 |
| 1656 |
| 1623 int Simulator::ReadW(int32_t addr, Instruction* instr) { | 1657 int Simulator::ReadW(int32_t addr, Instruction* instr) { |
| 1624 if (addr >=0 && addr < 0x400) { | 1658 if (addr >=0 && addr < 0x400) { |
| 1625 // This has to be a NULL-dereference, drop into debugger. | 1659 // This has to be a NULL-dereference, drop into debugger. |
| 1626 PrintF("Memory read from bad address: 0x%08x, pc=0x%08x\n", | 1660 PrintF("Memory read from bad address: 0x%08x, pc=0x%08x\n", |
| 1627 addr, reinterpret_cast<intptr_t>(instr)); | 1661 addr, reinterpret_cast<intptr_t>(instr)); |
| 1628 MipsDebugger dbg(this); | 1662 MipsDebugger dbg(this); |
| 1629 dbg.Debug(); | 1663 dbg.Debug(); |
| 1630 } | 1664 } |
| 1631 if ((addr & kPointerAlignmentMask) == 0) { | 1665 if ((addr & kPointerAlignmentMask) == 0) { |
| 1632 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); | 1666 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
| 1667 TraceMemRd(addr, static_cast<int32_t>(*ptr)); |
| 1633 return *ptr; | 1668 return *ptr; |
| 1634 } | 1669 } |
| 1635 PrintF("Unaligned read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1670 PrintF("Unaligned read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| 1636 addr, | 1671 addr, |
| 1637 reinterpret_cast<intptr_t>(instr)); | 1672 reinterpret_cast<intptr_t>(instr)); |
| 1638 MipsDebugger dbg(this); | 1673 MipsDebugger dbg(this); |
| 1639 dbg.Debug(); | 1674 dbg.Debug(); |
| 1640 return 0; | 1675 return 0; |
| 1641 } | 1676 } |
| 1642 | 1677 |
| 1643 | 1678 |
| 1644 void Simulator::WriteW(int32_t addr, int value, Instruction* instr) { | 1679 void Simulator::WriteW(int32_t addr, int value, Instruction* instr) { |
| 1645 if (addr >= 0 && addr < 0x400) { | 1680 if (addr >= 0 && addr < 0x400) { |
| 1646 // This has to be a NULL-dereference, drop into debugger. | 1681 // This has to be a NULL-dereference, drop into debugger. |
| 1647 PrintF("Memory write to bad address: 0x%08x, pc=0x%08x\n", | 1682 PrintF("Memory write to bad address: 0x%08x, pc=0x%08x\n", |
| 1648 addr, reinterpret_cast<intptr_t>(instr)); | 1683 addr, reinterpret_cast<intptr_t>(instr)); |
| 1649 MipsDebugger dbg(this); | 1684 MipsDebugger dbg(this); |
| 1650 dbg.Debug(); | 1685 dbg.Debug(); |
| 1651 } | 1686 } |
| 1652 if ((addr & kPointerAlignmentMask) == 0) { | 1687 if ((addr & kPointerAlignmentMask) == 0) { |
| 1653 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); | 1688 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
| 1689 TraceMemWr(addr, value, WORD); |
| 1654 *ptr = value; | 1690 *ptr = value; |
| 1655 return; | 1691 return; |
| 1656 } | 1692 } |
| 1657 PrintF("Unaligned write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1693 PrintF("Unaligned write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| 1658 addr, | 1694 addr, |
| 1659 reinterpret_cast<intptr_t>(instr)); | 1695 reinterpret_cast<intptr_t>(instr)); |
| 1660 MipsDebugger dbg(this); | 1696 MipsDebugger dbg(this); |
| 1661 dbg.Debug(); | 1697 dbg.Debug(); |
| 1662 } | 1698 } |
| 1663 | 1699 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1684 PrintF("Unaligned (double) write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1720 PrintF("Unaligned (double) write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| 1685 addr, | 1721 addr, |
| 1686 reinterpret_cast<intptr_t>(instr)); | 1722 reinterpret_cast<intptr_t>(instr)); |
| 1687 base::OS::Abort(); | 1723 base::OS::Abort(); |
| 1688 } | 1724 } |
| 1689 | 1725 |
| 1690 | 1726 |
| 1691 uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) { | 1727 uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) { |
| 1692 if ((addr & 1) == 0) { | 1728 if ((addr & 1) == 0) { |
| 1693 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); | 1729 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
| 1730 TraceMemRd(addr, static_cast<int32_t>(*ptr)); |
| 1694 return *ptr; | 1731 return *ptr; |
| 1695 } | 1732 } |
| 1696 PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1733 PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| 1697 addr, | 1734 addr, |
| 1698 reinterpret_cast<intptr_t>(instr)); | 1735 reinterpret_cast<intptr_t>(instr)); |
| 1699 base::OS::Abort(); | 1736 base::OS::Abort(); |
| 1700 return 0; | 1737 return 0; |
| 1701 } | 1738 } |
| 1702 | 1739 |
| 1703 | 1740 |
| 1704 int16_t Simulator::ReadH(int32_t addr, Instruction* instr) { | 1741 int16_t Simulator::ReadH(int32_t addr, Instruction* instr) { |
| 1705 if ((addr & 1) == 0) { | 1742 if ((addr & 1) == 0) { |
| 1706 int16_t* ptr = reinterpret_cast<int16_t*>(addr); | 1743 int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
| 1744 TraceMemRd(addr, static_cast<int32_t>(*ptr)); |
| 1707 return *ptr; | 1745 return *ptr; |
| 1708 } | 1746 } |
| 1709 PrintF("Unaligned signed halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1747 PrintF("Unaligned signed halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| 1710 addr, | 1748 addr, |
| 1711 reinterpret_cast<intptr_t>(instr)); | 1749 reinterpret_cast<intptr_t>(instr)); |
| 1712 base::OS::Abort(); | 1750 base::OS::Abort(); |
| 1713 return 0; | 1751 return 0; |
| 1714 } | 1752 } |
| 1715 | 1753 |
| 1716 | 1754 |
| 1717 void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) { | 1755 void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) { |
| 1718 if ((addr & 1) == 0) { | 1756 if ((addr & 1) == 0) { |
| 1719 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); | 1757 uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
| 1758 TraceMemWr(addr, value, HALF); |
| 1720 *ptr = value; | 1759 *ptr = value; |
| 1721 return; | 1760 return; |
| 1722 } | 1761 } |
| 1723 PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1762 PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| 1724 addr, | 1763 addr, |
| 1725 reinterpret_cast<intptr_t>(instr)); | 1764 reinterpret_cast<intptr_t>(instr)); |
| 1726 base::OS::Abort(); | 1765 base::OS::Abort(); |
| 1727 } | 1766 } |
| 1728 | 1767 |
| 1729 | 1768 |
| 1730 void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) { | 1769 void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) { |
| 1731 if ((addr & 1) == 0) { | 1770 if ((addr & 1) == 0) { |
| 1732 int16_t* ptr = reinterpret_cast<int16_t*>(addr); | 1771 int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
| 1772 TraceMemWr(addr, value, HALF); |
| 1733 *ptr = value; | 1773 *ptr = value; |
| 1734 return; | 1774 return; |
| 1735 } | 1775 } |
| 1736 PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1776 PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| 1737 addr, | 1777 addr, |
| 1738 reinterpret_cast<intptr_t>(instr)); | 1778 reinterpret_cast<intptr_t>(instr)); |
| 1739 base::OS::Abort(); | 1779 base::OS::Abort(); |
| 1740 } | 1780 } |
| 1741 | 1781 |
| 1742 | 1782 |
| 1743 uint32_t Simulator::ReadBU(int32_t addr) { | 1783 uint32_t Simulator::ReadBU(int32_t addr) { |
| 1744 uint8_t* ptr = reinterpret_cast<uint8_t*>(addr); | 1784 uint8_t* ptr = reinterpret_cast<uint8_t*>(addr); |
| 1785 TraceMemRd(addr, static_cast<int32_t>(*ptr)); |
| 1745 return *ptr & 0xff; | 1786 return *ptr & 0xff; |
| 1746 } | 1787 } |
| 1747 | 1788 |
| 1748 | 1789 |
| 1749 int32_t Simulator::ReadB(int32_t addr) { | 1790 int32_t Simulator::ReadB(int32_t addr) { |
| 1750 int8_t* ptr = reinterpret_cast<int8_t*>(addr); | 1791 int8_t* ptr = reinterpret_cast<int8_t*>(addr); |
| 1792 TraceMemRd(addr, static_cast<int32_t>(*ptr)); |
| 1751 return *ptr; | 1793 return *ptr; |
| 1752 } | 1794 } |
| 1753 | 1795 |
| 1754 | 1796 |
| 1755 void Simulator::WriteB(int32_t addr, uint8_t value) { | 1797 void Simulator::WriteB(int32_t addr, uint8_t value) { |
| 1756 uint8_t* ptr = reinterpret_cast<uint8_t*>(addr); | 1798 uint8_t* ptr = reinterpret_cast<uint8_t*>(addr); |
| 1799 TraceMemWr(addr, value, BYTE); |
| 1757 *ptr = value; | 1800 *ptr = value; |
| 1758 } | 1801 } |
| 1759 | 1802 |
| 1760 | 1803 |
| 1761 void Simulator::WriteB(int32_t addr, int8_t value) { | 1804 void Simulator::WriteB(int32_t addr, int8_t value) { |
| 1762 int8_t* ptr = reinterpret_cast<int8_t*>(addr); | 1805 int8_t* ptr = reinterpret_cast<int8_t*>(addr); |
| 1806 TraceMemWr(addr, value, BYTE); |
| 1763 *ptr = value; | 1807 *ptr = value; |
| 1764 } | 1808 } |
| 1765 | 1809 |
| 1766 | 1810 |
| 1767 // Returns the limit of the stack area to enable checking for stack overflows. | 1811 // Returns the limit of the stack area to enable checking for stack overflows. |
| 1768 uintptr_t Simulator::StackLimit() const { | 1812 uintptr_t Simulator::StackLimit() const { |
| 1769 // Leave a safety margin of 1024 bytes to prevent overrunning the stack when | 1813 // Leave a safety margin of 1024 bytes to prevent overrunning the stack when |
| 1770 // pushing values. | 1814 // pushing values. |
| 1771 return reinterpret_cast<uintptr_t>(stack_) + 1024; | 1815 return reinterpret_cast<uintptr_t>(stack_) + 1024; |
| 1772 } | 1816 } |
| (...skipping 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3706 case TLT: | 3750 case TLT: |
| 3707 case TLTU: | 3751 case TLTU: |
| 3708 case TEQ: | 3752 case TEQ: |
| 3709 case TNE: | 3753 case TNE: |
| 3710 if (do_interrupt) { | 3754 if (do_interrupt) { |
| 3711 SoftwareInterrupt(instr); | 3755 SoftwareInterrupt(instr); |
| 3712 } | 3756 } |
| 3713 break; | 3757 break; |
| 3714 // Conditional moves. | 3758 // Conditional moves. |
| 3715 case MOVN: | 3759 case MOVN: |
| 3716 if (rt) set_register(rd_reg, rs); | 3760 if (rt) { |
| 3761 set_register(rd_reg, rs); |
| 3762 TraceRegWr(rs); |
| 3763 } |
| 3717 break; | 3764 break; |
| 3718 case MOVCI: { | 3765 case MOVCI: { |
| 3719 uint32_t cc = instr->FBccValue(); | 3766 uint32_t cc = instr->FBccValue(); |
| 3720 uint32_t fcsr_cc = get_fcsr_condition_bit(cc); | 3767 uint32_t fcsr_cc = get_fcsr_condition_bit(cc); |
| 3721 if (instr->Bit(16)) { // Read Tf bit. | 3768 if (instr->Bit(16)) { // Read Tf bit. |
| 3722 if (test_fcsr_bit(fcsr_cc)) set_register(rd_reg, rs); | 3769 if (test_fcsr_bit(fcsr_cc)) set_register(rd_reg, rs); |
| 3723 } else { | 3770 } else { |
| 3724 if (!test_fcsr_bit(fcsr_cc)) set_register(rd_reg, rs); | 3771 if (!test_fcsr_bit(fcsr_cc)) set_register(rd_reg, rs); |
| 3725 } | 3772 } |
| 3726 break; | 3773 break; |
| 3727 } | 3774 } |
| 3728 case MOVZ: | 3775 case MOVZ: |
| 3729 if (!rt) set_register(rd_reg, rs); | 3776 if (!rt) { |
| 3777 set_register(rd_reg, rs); |
| 3778 TraceRegWr(rs); |
| 3779 } |
| 3730 break; | 3780 break; |
| 3731 default: // For other special opcodes we do the default operation. | 3781 default: // For other special opcodes we do the default operation. |
| 3732 set_register(rd_reg, alu_out); | 3782 set_register(rd_reg, alu_out); |
| 3783 TraceRegWr(alu_out); |
| 3733 } | 3784 } |
| 3734 } | 3785 } |
| 3735 | 3786 |
| 3736 | 3787 |
| 3737 void Simulator::DecodeTypeRegisterSPECIAL2(Instruction* instr, | 3788 void Simulator::DecodeTypeRegisterSPECIAL2(Instruction* instr, |
| 3738 const int32_t& rd_reg, | 3789 const int32_t& rd_reg, |
| 3739 int32_t& alu_out) { | 3790 int32_t& alu_out) { |
| 3740 switch (instr->FunctionFieldRaw()) { | 3791 switch (instr->FunctionFieldRaw()) { |
| 3741 case MUL: | 3792 case MUL: |
| 3742 set_register(rd_reg, alu_out); | 3793 set_register(rd_reg, alu_out); |
| 3794 TraceRegWr(alu_out); |
| 3743 // HI and LO are UNPREDICTABLE after the operation. | 3795 // HI and LO are UNPREDICTABLE after the operation. |
| 3744 set_register(LO, Unpredictable); | 3796 set_register(LO, Unpredictable); |
| 3745 set_register(HI, Unpredictable); | 3797 set_register(HI, Unpredictable); |
| 3746 break; | 3798 break; |
| 3747 default: // For other special2 opcodes we do the default operation. | 3799 default: // For other special2 opcodes we do the default operation. |
| 3748 set_register(rd_reg, alu_out); | 3800 set_register(rd_reg, alu_out); |
| 3801 TraceRegWr(alu_out); |
| 3749 } | 3802 } |
| 3750 } | 3803 } |
| 3751 | 3804 |
| 3752 | 3805 |
| 3753 void Simulator::DecodeTypeRegisterSPECIAL3(Instruction* instr, | 3806 void Simulator::DecodeTypeRegisterSPECIAL3(Instruction* instr, |
| 3754 const int32_t& rt_reg, | 3807 const int32_t& rt_reg, |
| 3755 const int32_t& rd_reg, | 3808 const int32_t& rd_reg, |
| 3756 int32_t& alu_out) { | 3809 int32_t& alu_out) { |
| 3757 switch (instr->FunctionFieldRaw()) { | 3810 switch (instr->FunctionFieldRaw()) { |
| 3758 case INS: | 3811 case INS: |
| 3759 // Ins instr leaves result in Rt, rather than Rd. | 3812 // Ins instr leaves result in Rt, rather than Rd. |
| 3760 set_register(rt_reg, alu_out); | 3813 set_register(rt_reg, alu_out); |
| 3814 TraceRegWr(alu_out); |
| 3761 break; | 3815 break; |
| 3762 case EXT: | 3816 case EXT: |
| 3763 // Ext instr leaves result in Rt, rather than Rd. | 3817 // Ext instr leaves result in Rt, rather than Rd. |
| 3764 set_register(rt_reg, alu_out); | 3818 set_register(rt_reg, alu_out); |
| 3819 TraceRegWr(alu_out); |
| 3765 break; | 3820 break; |
| 3766 case BITSWAP: | 3821 case BITSWAP: |
| 3767 set_register(rd_reg, alu_out); | 3822 set_register(rd_reg, alu_out); |
| 3823 TraceRegWr(alu_out); |
| 3768 break; | 3824 break; |
| 3769 default: | 3825 default: |
| 3770 UNREACHABLE(); | 3826 UNREACHABLE(); |
| 3771 } | 3827 } |
| 3772 } | 3828 } |
| 3773 | 3829 |
| 3774 | 3830 |
| 3775 void Simulator::DecodeTypeRegister(Instruction* instr) { | 3831 void Simulator::DecodeTypeRegister(Instruction* instr) { |
| 3776 // Instruction fields. | 3832 // Instruction fields. |
| 3777 const Opcode op = instr->OpcodeFieldRaw(); | 3833 const Opcode op = instr->OpcodeFieldRaw(); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4122 // ------------- Arithmetic instructions. | 4178 // ------------- Arithmetic instructions. |
| 4123 case ADDI: | 4179 case ADDI: |
| 4124 case ADDIU: | 4180 case ADDIU: |
| 4125 case SLTI: | 4181 case SLTI: |
| 4126 case SLTIU: | 4182 case SLTIU: |
| 4127 case ANDI: | 4183 case ANDI: |
| 4128 case ORI: | 4184 case ORI: |
| 4129 case XORI: | 4185 case XORI: |
| 4130 case LUI: | 4186 case LUI: |
| 4131 set_register(rt_reg, alu_out); | 4187 set_register(rt_reg, alu_out); |
| 4188 TraceRegWr(alu_out); |
| 4132 break; | 4189 break; |
| 4133 // ------------- Memory instructions. | 4190 // ------------- Memory instructions. |
| 4134 case LB: | 4191 case LB: |
| 4135 case LH: | 4192 case LH: |
| 4136 case LWL: | 4193 case LWL: |
| 4137 case LW: | 4194 case LW: |
| 4138 case LBU: | 4195 case LBU: |
| 4139 case LHU: | 4196 case LHU: |
| 4140 case LWR: | 4197 case LWR: |
| 4141 set_register(rt_reg, alu_out); | 4198 set_register(rt_reg, alu_out); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4216 pc_modified_ = true; | 4273 pc_modified_ = true; |
| 4217 } | 4274 } |
| 4218 | 4275 |
| 4219 | 4276 |
| 4220 // Executes the current instruction. | 4277 // Executes the current instruction. |
| 4221 void Simulator::InstructionDecode(Instruction* instr) { | 4278 void Simulator::InstructionDecode(Instruction* instr) { |
| 4222 if (v8::internal::FLAG_check_icache) { | 4279 if (v8::internal::FLAG_check_icache) { |
| 4223 CheckICache(isolate_->simulator_i_cache(), instr); | 4280 CheckICache(isolate_->simulator_i_cache(), instr); |
| 4224 } | 4281 } |
| 4225 pc_modified_ = false; | 4282 pc_modified_ = false; |
| 4283 v8::internal::EmbeddedVector<char, 256> buffer; |
| 4226 if (::v8::internal::FLAG_trace_sim) { | 4284 if (::v8::internal::FLAG_trace_sim) { |
| 4285 SNPrintF(trace_buf_, "%s", ""); |
| 4227 disasm::NameConverter converter; | 4286 disasm::NameConverter converter; |
| 4228 disasm::Disassembler dasm(converter); | 4287 disasm::Disassembler dasm(converter); |
| 4229 // Use a reasonably large buffer. | |
| 4230 v8::internal::EmbeddedVector<char, 256> buffer; | |
| 4231 dasm.InstructionDecode(buffer, reinterpret_cast<byte*>(instr)); | 4288 dasm.InstructionDecode(buffer, reinterpret_cast<byte*>(instr)); |
| 4232 PrintF(" 0x%08x %s\n", reinterpret_cast<intptr_t>(instr), | |
| 4233 buffer.start()); | |
| 4234 } | 4289 } |
| 4235 | 4290 |
| 4236 switch (instr->InstructionType()) { | 4291 switch (instr->InstructionType()) { |
| 4237 case Instruction::kRegisterType: | 4292 case Instruction::kRegisterType: |
| 4238 DecodeTypeRegister(instr); | 4293 DecodeTypeRegister(instr); |
| 4239 break; | 4294 break; |
| 4240 case Instruction::kImmediateType: | 4295 case Instruction::kImmediateType: |
| 4241 DecodeTypeImmediate(instr); | 4296 DecodeTypeImmediate(instr); |
| 4242 break; | 4297 break; |
| 4243 case Instruction::kJumpType: | 4298 case Instruction::kJumpType: |
| 4244 DecodeTypeJump(instr); | 4299 DecodeTypeJump(instr); |
| 4245 break; | 4300 break; |
| 4246 default: | 4301 default: |
| 4247 UNSUPPORTED(); | 4302 UNSUPPORTED(); |
| 4248 } | 4303 } |
| 4304 if (::v8::internal::FLAG_trace_sim) { |
| 4305 PrintF(" 0x%08x %-44s %s\n", reinterpret_cast<intptr_t>(instr), |
| 4306 buffer.start(), trace_buf_.start()); |
| 4307 } |
| 4249 if (!pc_modified_) { | 4308 if (!pc_modified_) { |
| 4250 set_register(pc, reinterpret_cast<int32_t>(instr) + | 4309 set_register(pc, reinterpret_cast<int32_t>(instr) + |
| 4251 Instruction::kInstrSize); | 4310 Instruction::kInstrSize); |
| 4252 } | 4311 } |
| 4253 } | 4312 } |
| 4254 | 4313 |
| 4255 | 4314 |
| 4256 | 4315 |
| 4257 void Simulator::Execute() { | 4316 void Simulator::Execute() { |
| 4258 // Get the PC to simulate. Cannot use the accessor here as we need the | 4317 // Get the PC to simulate. Cannot use the accessor here as we need the |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4431 | 4490 |
| 4432 | 4491 |
| 4433 #undef UNSUPPORTED | 4492 #undef UNSUPPORTED |
| 4434 | 4493 |
| 4435 } // namespace internal | 4494 } // namespace internal |
| 4436 } // namespace v8 | 4495 } // namespace v8 |
| 4437 | 4496 |
| 4438 #endif // USE_SIMULATOR | 4497 #endif // USE_SIMULATOR |
| 4439 | 4498 |
| 4440 #endif // V8_TARGET_ARCH_MIPS | 4499 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |