| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <stdlib.h> | 28 #include <stdlib.h> |
| 29 #include <cstdarg> | 29 #include <cstdarg> |
| 30 #include "v8.h" | 30 #include "v8.h" |
| 31 | 31 |
| 32 #include "disasm.h" | 32 #include "disasm.h" |
| 33 #include "assembler.h" | 33 #include "assembler.h" |
| 34 #include "globals.h" // Need the bit_cast | 34 #include "globals.h" // Need the BitCast |
| 35 #include "mips/constants-mips.h" | 35 #include "mips/constants-mips.h" |
| 36 #include "mips/simulator-mips.h" | 36 #include "mips/simulator-mips.h" |
| 37 | 37 |
| 38 namespace v8i = v8::internal; | 38 namespace v8i = v8::internal; |
| 39 | 39 |
| 40 #if !defined(__mips) | 40 #if !defined(__mips) |
| 41 | 41 |
| 42 // Only build the simulator if not compiling for real MIPS hardware. | 42 // Only build the simulator if not compiling for real MIPS hardware. |
| 43 namespace assembler { | 43 namespace assembler { |
| 44 namespace mips { | 44 namespace mips { |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 registers_[reg] = (reg == 0) ? 0 : value; | 597 registers_[reg] = (reg == 0) ? 0 : value; |
| 598 } | 598 } |
| 599 | 599 |
| 600 void Simulator::set_fpu_register(int fpureg, int32_t value) { | 600 void Simulator::set_fpu_register(int fpureg, int32_t value) { |
| 601 ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters)); | 601 ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters)); |
| 602 FPUregisters_[fpureg] = value; | 602 FPUregisters_[fpureg] = value; |
| 603 } | 603 } |
| 604 | 604 |
| 605 void Simulator::set_fpu_register_double(int fpureg, double value) { | 605 void Simulator::set_fpu_register_double(int fpureg, double value) { |
| 606 ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0)); | 606 ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0)); |
| 607 *v8i::bit_cast<double*, int32_t*>(&FPUregisters_[fpureg]) = value; | 607 *v8i::BitCast<double*, int32_t*>(&FPUregisters_[fpureg]) = value; |
| 608 } | 608 } |
| 609 | 609 |
| 610 | 610 |
| 611 // Get the register from the architecture state. This function does handle | 611 // Get the register from the architecture state. This function does handle |
| 612 // the special case of accessing the PC register. | 612 // the special case of accessing the PC register. |
| 613 int32_t Simulator::get_register(int reg) const { | 613 int32_t Simulator::get_register(int reg) const { |
| 614 ASSERT((reg >= 0) && (reg < kNumSimuRegisters)); | 614 ASSERT((reg >= 0) && (reg < kNumSimuRegisters)); |
| 615 if (reg == 0) | 615 if (reg == 0) |
| 616 return 0; | 616 return 0; |
| 617 else | 617 else |
| 618 return registers_[reg] + ((reg == pc) ? Instruction::kPCReadOffset : 0); | 618 return registers_[reg] + ((reg == pc) ? Instruction::kPCReadOffset : 0); |
| 619 } | 619 } |
| 620 | 620 |
| 621 int32_t Simulator::get_fpu_register(int fpureg) const { | 621 int32_t Simulator::get_fpu_register(int fpureg) const { |
| 622 ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters)); | 622 ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters)); |
| 623 return FPUregisters_[fpureg]; | 623 return FPUregisters_[fpureg]; |
| 624 } | 624 } |
| 625 | 625 |
| 626 double Simulator::get_fpu_register_double(int fpureg) const { | 626 double Simulator::get_fpu_register_double(int fpureg) const { |
| 627 ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0)); | 627 ASSERT((fpureg >= 0) && (fpureg < kNumFPURegisters) && ((fpureg % 2) == 0)); |
| 628 return *v8i::bit_cast<double*, int32_t*>( | 628 return *v8i::BitCast<double*, int32_t*>( |
| 629 const_cast<int32_t*>(&FPUregisters_[fpureg])); | 629 const_cast<int32_t*>(&FPUregisters_[fpureg])); |
| 630 } | 630 } |
| 631 | 631 |
| 632 // Raw access to the PC register. | 632 // Raw access to the PC register. |
| 633 void Simulator::set_pc(int32_t value) { | 633 void Simulator::set_pc(int32_t value) { |
| 634 pc_modified_ = true; | 634 pc_modified_ = true; |
| 635 registers_[pc] = value; | 635 registers_[pc] = value; |
| 636 } | 636 } |
| 637 | 637 |
| 638 // Raw access to the PC register without the special adjustment when reading. | 638 // Raw access to the PC register without the special adjustment when reading. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 case COP1: // Coprocessor instructions | 894 case COP1: // Coprocessor instructions |
| 895 switch (instr->RsFieldRaw()) { | 895 switch (instr->RsFieldRaw()) { |
| 896 case BC1: // branch on coprocessor condition | 896 case BC1: // branch on coprocessor condition |
| 897 UNREACHABLE(); | 897 UNREACHABLE(); |
| 898 break; | 898 break; |
| 899 case MFC1: | 899 case MFC1: |
| 900 alu_out = get_fpu_register(fs_reg); | 900 alu_out = get_fpu_register(fs_reg); |
| 901 break; | 901 break; |
| 902 case MFHC1: | 902 case MFHC1: |
| 903 fp_out = get_fpu_register_double(fs_reg); | 903 fp_out = get_fpu_register_double(fs_reg); |
| 904 alu_out = *v8i::bit_cast<int32_t*, double*>(&fp_out); | 904 alu_out = *v8i::BitCast<int32_t*, double*>(&fp_out); |
| 905 break; | 905 break; |
| 906 case MTC1: | 906 case MTC1: |
| 907 case MTHC1: | 907 case MTHC1: |
| 908 // Do the store in the execution step. | 908 // Do the store in the execution step. |
| 909 break; | 909 break; |
| 910 case S: | 910 case S: |
| 911 case D: | 911 case D: |
| 912 case W: | 912 case W: |
| 913 case L: | 913 case L: |
| 914 case PS: | 914 case PS: |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 return address; | 1639 return address; |
| 1640 } | 1640 } |
| 1641 | 1641 |
| 1642 | 1642 |
| 1643 #undef UNSUPPORTED | 1643 #undef UNSUPPORTED |
| 1644 | 1644 |
| 1645 } } // namespace assembler::mips | 1645 } } // namespace assembler::mips |
| 1646 | 1646 |
| 1647 #endif // !defined(__mips) | 1647 #endif // !defined(__mips) |
| 1648 | 1648 |
| OLD | NEW |