| 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 <stdarg.h> | 5 #include <stdarg.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #if V8_TARGET_ARCH_S390 | 9 #if V8_TARGET_ARCH_S390 |
| 10 | 10 |
| (...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 registers_[3] = 0x50Bad4U; | 1786 registers_[3] = 0x50Bad4U; |
| 1787 registers_[12] = 0x50Bad4U; | 1787 registers_[12] = 0x50Bad4U; |
| 1788 #endif | 1788 #endif |
| 1789 } | 1789 } |
| 1790 | 1790 |
| 1791 uint32_t Simulator::ReadWU(intptr_t addr, Instruction* instr) { | 1791 uint32_t Simulator::ReadWU(intptr_t addr, Instruction* instr) { |
| 1792 uint32_t* ptr = reinterpret_cast<uint32_t*>(addr); | 1792 uint32_t* ptr = reinterpret_cast<uint32_t*>(addr); |
| 1793 return *ptr; | 1793 return *ptr; |
| 1794 } | 1794 } |
| 1795 | 1795 |
| 1796 int64_t Simulator::ReadW64(intptr_t addr, Instruction* instr) { |
| 1797 int64_t* ptr = reinterpret_cast<int64_t*>(addr); |
| 1798 return *ptr; |
| 1799 } |
| 1800 |
| 1796 int32_t Simulator::ReadW(intptr_t addr, Instruction* instr) { | 1801 int32_t Simulator::ReadW(intptr_t addr, Instruction* instr) { |
| 1797 int32_t* ptr = reinterpret_cast<int32_t*>(addr); | 1802 int32_t* ptr = reinterpret_cast<int32_t*>(addr); |
| 1798 return *ptr; | 1803 return *ptr; |
| 1799 } | 1804 } |
| 1800 | 1805 |
| 1801 void Simulator::WriteW(intptr_t addr, uint32_t value, Instruction* instr) { | 1806 void Simulator::WriteW(intptr_t addr, uint32_t value, Instruction* instr) { |
| 1802 uint32_t* ptr = reinterpret_cast<uint32_t*>(addr); | 1807 uint32_t* ptr = reinterpret_cast<uint32_t*>(addr); |
| 1803 *ptr = value; | 1808 *ptr = value; |
| 1804 return; | 1809 return; |
| 1805 } | 1810 } |
| (...skipping 3745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5551 break; | 5556 break; |
| 5552 } | 5557 } |
| 5553 default: | 5558 default: |
| 5554 UNREACHABLE(); | 5559 UNREACHABLE(); |
| 5555 return false; | 5560 return false; |
| 5556 } | 5561 } |
| 5557 return true; | 5562 return true; |
| 5558 } | 5563 } |
| 5559 | 5564 |
| 5560 int16_t Simulator::ByteReverse(int16_t hword) { | 5565 int16_t Simulator::ByteReverse(int16_t hword) { |
| 5566 #if defined(__GNUC__) |
| 5567 return __builtin_bswap16(hword); |
| 5568 #else |
| 5561 return (hword << 8) | ((hword >> 8) & 0x00ff); | 5569 return (hword << 8) | ((hword >> 8) & 0x00ff); |
| 5570 #endif |
| 5562 } | 5571 } |
| 5563 | 5572 |
| 5564 int32_t Simulator::ByteReverse(int32_t word) { | 5573 int32_t Simulator::ByteReverse(int32_t word) { |
| 5574 #if defined(__GNUC__) |
| 5575 return __builtin_bswap32(word); |
| 5576 #else |
| 5565 int32_t result = word << 24; | 5577 int32_t result = word << 24; |
| 5566 result |= (word << 8) & 0x00ff0000; | 5578 result |= (word << 8) & 0x00ff0000; |
| 5567 result |= (word >> 8) & 0x0000ff00; | 5579 result |= (word >> 8) & 0x0000ff00; |
| 5568 result |= (word >> 24) & 0x00000ff; | 5580 result |= (word >> 24) & 0x00000ff; |
| 5569 return result; | 5581 return result; |
| 5582 #endif |
| 5583 } |
| 5584 |
| 5585 int64_t Simulator::ByteReverse(int64_t dword) { |
| 5586 #if defined(__GNUC__) |
| 5587 return __builtin_bswap64(dword); |
| 5588 #else |
| 5589 #error unsupport __builtin_bswap64 |
| 5590 #endif |
| 5570 } | 5591 } |
| 5571 | 5592 |
| 5572 int Simulator::DecodeInstructionOriginal(Instruction* instr) { | 5593 int Simulator::DecodeInstructionOriginal(Instruction* instr) { |
| 5573 int instrLength = instr->InstructionLength(); | 5594 int instrLength = instr->InstructionLength(); |
| 5574 bool processed = true; | 5595 bool processed = true; |
| 5575 if (instrLength == 2) | 5596 if (instrLength == 2) |
| 5576 processed = DecodeTwoByte(instr); | 5597 processed = DecodeTwoByte(instr); |
| 5577 else if (instrLength == 4) | 5598 else if (instrLength == 4) |
| 5578 processed = DecodeFourByte(instr); | 5599 processed = DecodeFourByte(instr); |
| 5579 else if (instrLength == 6) | 5600 else if (instrLength == 6) |
| (...skipping 4280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9860 DCHECK(r1 % 2 == 0); | 9881 DCHECK(r1 % 2 == 0); |
| 9861 | 9882 |
| 9862 int64_t dividend = get_register(r1 + 1); | 9883 int64_t dividend = get_register(r1 + 1); |
| 9863 int64_t divisor = get_register(r2); | 9884 int64_t divisor = get_register(r2); |
| 9864 set_register(r1, dividend % divisor); | 9885 set_register(r1, dividend % divisor); |
| 9865 set_register(r1 + 1, dividend / divisor); | 9886 set_register(r1 + 1, dividend / divisor); |
| 9866 return length; | 9887 return length; |
| 9867 } | 9888 } |
| 9868 | 9889 |
| 9869 EVALUATE(LRVGR) { | 9890 EVALUATE(LRVGR) { |
| 9870 UNIMPLEMENTED(); | 9891 DCHECK_OPCODE(LRVGR); |
| 9871 USE(instr); | 9892 DECODE_RRE_INSTRUCTION(r1, r2); |
| 9872 return 0; | 9893 int64_t r2_val = get_register(r2); |
| 9894 int64_t r1_val = ByteReverse(r2_val); |
| 9895 |
| 9896 set_register(r1, r1_val); |
| 9897 return length; |
| 9873 } | 9898 } |
| 9874 | 9899 |
| 9875 EVALUATE(LPGFR) { | 9900 EVALUATE(LPGFR) { |
| 9876 UNIMPLEMENTED(); | 9901 UNIMPLEMENTED(); |
| 9877 USE(instr); | 9902 USE(instr); |
| 9878 return 0; | 9903 return 0; |
| 9879 } | 9904 } |
| 9880 | 9905 |
| 9881 EVALUATE(LNGFR) { | 9906 EVALUATE(LNGFR) { |
| 9882 UNIMPLEMENTED(); | 9907 UNIMPLEMENTED(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9975 return 0; | 10000 return 0; |
| 9976 } | 10001 } |
| 9977 | 10002 |
| 9978 EVALUATE(KMAC) { | 10003 EVALUATE(KMAC) { |
| 9979 UNIMPLEMENTED(); | 10004 UNIMPLEMENTED(); |
| 9980 USE(instr); | 10005 USE(instr); |
| 9981 return 0; | 10006 return 0; |
| 9982 } | 10007 } |
| 9983 | 10008 |
| 9984 EVALUATE(LRVR) { | 10009 EVALUATE(LRVR) { |
| 9985 UNIMPLEMENTED(); | 10010 DCHECK_OPCODE(LRVR); |
| 9986 USE(instr); | 10011 DECODE_RRE_INSTRUCTION(r1, r2); |
| 9987 return 0; | 10012 int32_t r2_val = get_low_register<int32_t>(r2); |
| 10013 int32_t r1_val = ByteReverse(r2_val); |
| 10014 |
| 10015 set_low_register(r1, r1_val); |
| 10016 return length; |
| 9988 } | 10017 } |
| 9989 | 10018 |
| 9990 EVALUATE(CGR) { | 10019 EVALUATE(CGR) { |
| 9991 DCHECK_OPCODE(CGR); | 10020 DCHECK_OPCODE(CGR); |
| 9992 DECODE_RRE_INSTRUCTION(r1, r2); | 10021 DECODE_RRE_INSTRUCTION(r1, r2); |
| 9993 // Compare (64) | 10022 // Compare (64) |
| 9994 int64_t r1_val = get_register(r1); | 10023 int64_t r1_val = get_register(r1); |
| 9995 int64_t r2_val = get_register(r2); | 10024 int64_t r2_val = get_register(r2); |
| 9996 SetS390ConditionCode<int64_t>(r1_val, r2_val); | 10025 SetS390ConditionCode<int64_t>(r1_val, r2_val); |
| 9997 return length; | 10026 return length; |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10776 USE(instr); | 10805 USE(instr); |
| 10777 return 0; | 10806 return 0; |
| 10778 } | 10807 } |
| 10779 | 10808 |
| 10780 EVALUATE(CVBG) { | 10809 EVALUATE(CVBG) { |
| 10781 UNIMPLEMENTED(); | 10810 UNIMPLEMENTED(); |
| 10782 USE(instr); | 10811 USE(instr); |
| 10783 return 0; | 10812 return 0; |
| 10784 } | 10813 } |
| 10785 | 10814 |
| 10786 EVALUATE(LRVG) { | |
| 10787 UNIMPLEMENTED(); | |
| 10788 USE(instr); | |
| 10789 return 0; | |
| 10790 } | |
| 10791 | |
| 10792 EVALUATE(LT) { | 10815 EVALUATE(LT) { |
| 10793 DCHECK_OPCODE(LT); | 10816 DCHECK_OPCODE(LT); |
| 10794 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 10817 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 10795 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 10818 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 10796 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 10819 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 10797 intptr_t addr = x2_val + b2_val + d2; | 10820 intptr_t addr = x2_val + b2_val + d2; |
| 10798 int32_t value = ReadW(addr, instr); | 10821 int32_t value = ReadW(addr, instr); |
| 10799 set_low_register(r1, value); | 10822 set_low_register(r1, value); |
| 10800 SetS390ConditionCode<int32_t>(value, 0); | 10823 SetS390ConditionCode<int32_t>(value, 0); |
| 10801 return length; | 10824 return length; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10878 USE(instr); | 10901 USE(instr); |
| 10879 return 0; | 10902 return 0; |
| 10880 } | 10903 } |
| 10881 | 10904 |
| 10882 EVALUATE(DSGF) { | 10905 EVALUATE(DSGF) { |
| 10883 UNIMPLEMENTED(); | 10906 UNIMPLEMENTED(); |
| 10884 USE(instr); | 10907 USE(instr); |
| 10885 return 0; | 10908 return 0; |
| 10886 } | 10909 } |
| 10887 | 10910 |
| 10911 EVALUATE(LRVG) { |
| 10912 DCHECK_OPCODE(LRVG); |
| 10913 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 10914 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 10915 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 10916 intptr_t mem_addr = b2_val + x2_val + d2; |
| 10917 int64_t mem_val = ReadW64(mem_addr, instr); |
| 10918 set_register(r1, ByteReverse(mem_val)); |
| 10919 return length; |
| 10920 } |
| 10921 |
| 10888 EVALUATE(LRV) { | 10922 EVALUATE(LRV) { |
| 10889 DCHECK_OPCODE(LRV); | 10923 DCHECK_OPCODE(LRV); |
| 10890 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 10924 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 10891 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 10925 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 10892 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 10926 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 10893 intptr_t mem_addr = b2_val + x2_val + d2; | 10927 intptr_t mem_addr = b2_val + x2_val + d2; |
| 10894 int32_t mem_val = ReadW(mem_addr, instr); | 10928 int32_t mem_val = ReadW(mem_addr, instr); |
| 10895 set_low_register(r1, ByteReverse(mem_val)); | 10929 set_low_register(r1, ByteReverse(mem_val)); |
| 10896 return length; | 10930 return length; |
| 10897 } | 10931 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10945 USE(instr); | 10979 USE(instr); |
| 10946 return 0; | 10980 return 0; |
| 10947 } | 10981 } |
| 10948 | 10982 |
| 10949 EVALUATE(CVDG) { | 10983 EVALUATE(CVDG) { |
| 10950 UNIMPLEMENTED(); | 10984 UNIMPLEMENTED(); |
| 10951 USE(instr); | 10985 USE(instr); |
| 10952 return 0; | 10986 return 0; |
| 10953 } | 10987 } |
| 10954 | 10988 |
| 10955 EVALUATE(STRVG) { | |
| 10956 UNIMPLEMENTED(); | |
| 10957 USE(instr); | |
| 10958 return 0; | |
| 10959 } | |
| 10960 | |
| 10961 EVALUATE(CGF) { | 10989 EVALUATE(CGF) { |
| 10962 UNIMPLEMENTED(); | 10990 UNIMPLEMENTED(); |
| 10963 USE(instr); | 10991 USE(instr); |
| 10964 return 0; | 10992 return 0; |
| 10965 } | 10993 } |
| 10966 | 10994 |
| 10967 EVALUATE(CLGF) { | 10995 EVALUATE(CLGF) { |
| 10968 UNIMPLEMENTED(); | 10996 UNIMPLEMENTED(); |
| 10969 USE(instr); | 10997 USE(instr); |
| 10970 return 0; | 10998 return 0; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 10992 DCHECK_OPCODE(STRV); | 11020 DCHECK_OPCODE(STRV); |
| 10993 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 11021 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 10994 int32_t r1_val = get_low_register<int32_t>(r1); | 11022 int32_t r1_val = get_low_register<int32_t>(r1); |
| 10995 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 11023 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 10996 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 11024 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 10997 intptr_t mem_addr = b2_val + x2_val + d2; | 11025 intptr_t mem_addr = b2_val + x2_val + d2; |
| 10998 WriteW(mem_addr, ByteReverse(r1_val), instr); | 11026 WriteW(mem_addr, ByteReverse(r1_val), instr); |
| 10999 return length; | 11027 return length; |
| 11000 } | 11028 } |
| 11001 | 11029 |
| 11030 EVALUATE(STRVG) { |
| 11031 DCHECK_OPCODE(STRVG); |
| 11032 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 11033 int64_t r1_val = get_register(r1); |
| 11034 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 11035 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 11036 intptr_t mem_addr = b2_val + x2_val + d2; |
| 11037 WriteDW(mem_addr, ByteReverse(r1_val)); |
| 11038 return length; |
| 11039 } |
| 11040 |
| 11002 EVALUATE(STRVH) { | 11041 EVALUATE(STRVH) { |
| 11003 DCHECK_OPCODE(STRVH); | 11042 DCHECK_OPCODE(STRVH); |
| 11004 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 11043 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 11005 int32_t r1_val = get_low_register<int32_t>(r1); | 11044 int32_t r1_val = get_low_register<int32_t>(r1); |
| 11006 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 11045 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 11007 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 11046 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 11008 intptr_t mem_addr = b2_val + x2_val + d2; | 11047 intptr_t mem_addr = b2_val + x2_val + d2; |
| 11009 int16_t result = static_cast<int16_t>(r1_val >> 16); | 11048 int16_t result = static_cast<int16_t>(r1_val >> 16); |
| 11010 WriteH(mem_addr, ByteReverse(result), instr); | 11049 WriteH(mem_addr, ByteReverse(result), instr); |
| 11011 return length; | 11050 return length; |
| (...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12565 return 0; | 12604 return 0; |
| 12566 } | 12605 } |
| 12567 | 12606 |
| 12568 #undef EVALUATE | 12607 #undef EVALUATE |
| 12569 | 12608 |
| 12570 } // namespace internal | 12609 } // namespace internal |
| 12571 } // namespace v8 | 12610 } // namespace v8 |
| 12572 | 12611 |
| 12573 #endif // USE_SIMULATOR | 12612 #endif // USE_SIMULATOR |
| 12574 #endif // V8_TARGET_ARCH_S390 | 12613 #endif // V8_TARGET_ARCH_S390 |
| OLD | NEW |