| 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 4395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9975 return 0; | 9996 return 0; |
| 9976 } | 9997 } |
| 9977 | 9998 |
| 9978 EVALUATE(KMAC) { | 9999 EVALUATE(KMAC) { |
| 9979 UNIMPLEMENTED(); | 10000 UNIMPLEMENTED(); |
| 9980 USE(instr); | 10001 USE(instr); |
| 9981 return 0; | 10002 return 0; |
| 9982 } | 10003 } |
| 9983 | 10004 |
| 9984 EVALUATE(LRVR) { | 10005 EVALUATE(LRVR) { |
| 9985 UNIMPLEMENTED(); | 10006 DCHECK_OPCODE(LRVR); |
| 9986 USE(instr); | 10007 DECODE_RRE_INSTRUCTION(r1, r2); |
| 9987 return 0; | 10008 int32_t r2_val = get_low_register<int32_t>(r2); |
| 10009 int32_t r1_val = 0; |
| 10010 r1_val = ByteReverse(r2_val); |
| 10011 |
| 10012 set_low_register(r1, r1_val); |
| 10013 return length; |
| 9988 } | 10014 } |
| 9989 | 10015 |
| 9990 EVALUATE(CGR) { | 10016 EVALUATE(CGR) { |
| 9991 DCHECK_OPCODE(CGR); | 10017 DCHECK_OPCODE(CGR); |
| 9992 DECODE_RRE_INSTRUCTION(r1, r2); | 10018 DECODE_RRE_INSTRUCTION(r1, r2); |
| 9993 // Compare (64) | 10019 // Compare (64) |
| 9994 int64_t r1_val = get_register(r1); | 10020 int64_t r1_val = get_register(r1); |
| 9995 int64_t r2_val = get_register(r2); | 10021 int64_t r2_val = get_register(r2); |
| 9996 SetS390ConditionCode<int64_t>(r1_val, r2_val); | 10022 SetS390ConditionCode<int64_t>(r1_val, r2_val); |
| 9997 return length; | 10023 return length; |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10776 USE(instr); | 10802 USE(instr); |
| 10777 return 0; | 10803 return 0; |
| 10778 } | 10804 } |
| 10779 | 10805 |
| 10780 EVALUATE(CVBG) { | 10806 EVALUATE(CVBG) { |
| 10781 UNIMPLEMENTED(); | 10807 UNIMPLEMENTED(); |
| 10782 USE(instr); | 10808 USE(instr); |
| 10783 return 0; | 10809 return 0; |
| 10784 } | 10810 } |
| 10785 | 10811 |
| 10786 EVALUATE(LRVG) { | |
| 10787 UNIMPLEMENTED(); | |
| 10788 USE(instr); | |
| 10789 return 0; | |
| 10790 } | |
| 10791 | |
| 10792 EVALUATE(LT) { | 10812 EVALUATE(LT) { |
| 10793 DCHECK_OPCODE(LT); | 10813 DCHECK_OPCODE(LT); |
| 10794 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 10814 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 10795 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 10815 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 10796 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 10816 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 10797 intptr_t addr = x2_val + b2_val + d2; | 10817 intptr_t addr = x2_val + b2_val + d2; |
| 10798 int32_t value = ReadW(addr, instr); | 10818 int32_t value = ReadW(addr, instr); |
| 10799 set_low_register(r1, value); | 10819 set_low_register(r1, value); |
| 10800 SetS390ConditionCode<int32_t>(value, 0); | 10820 SetS390ConditionCode<int32_t>(value, 0); |
| 10801 return length; | 10821 return length; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10878 USE(instr); | 10898 USE(instr); |
| 10879 return 0; | 10899 return 0; |
| 10880 } | 10900 } |
| 10881 | 10901 |
| 10882 EVALUATE(DSGF) { | 10902 EVALUATE(DSGF) { |
| 10883 UNIMPLEMENTED(); | 10903 UNIMPLEMENTED(); |
| 10884 USE(instr); | 10904 USE(instr); |
| 10885 return 0; | 10905 return 0; |
| 10886 } | 10906 } |
| 10887 | 10907 |
| 10908 EVALUATE(LRVG) { |
| 10909 DCHECK_OPCODE(LRVG); |
| 10910 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 10911 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 10912 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 10913 intptr_t mem_addr = b2_val + x2_val + d2; |
| 10914 int64_t mem_val = ReadW64(mem_addr, instr); |
| 10915 set_register(r1, ByteReverse(mem_val)); |
| 10916 return length; |
| 10917 } |
| 10918 |
| 10888 EVALUATE(LRV) { | 10919 EVALUATE(LRV) { |
| 10889 DCHECK_OPCODE(LRV); | 10920 DCHECK_OPCODE(LRV); |
| 10890 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 10921 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 10891 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 10922 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 10892 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 10923 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 10893 intptr_t mem_addr = b2_val + x2_val + d2; | 10924 intptr_t mem_addr = b2_val + x2_val + d2; |
| 10894 int32_t mem_val = ReadW(mem_addr, instr); | 10925 int32_t mem_val = ReadW(mem_addr, instr); |
| 10895 set_low_register(r1, ByteReverse(mem_val)); | 10926 set_low_register(r1, ByteReverse(mem_val)); |
| 10896 return length; | 10927 return length; |
| 10897 } | 10928 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10945 USE(instr); | 10976 USE(instr); |
| 10946 return 0; | 10977 return 0; |
| 10947 } | 10978 } |
| 10948 | 10979 |
| 10949 EVALUATE(CVDG) { | 10980 EVALUATE(CVDG) { |
| 10950 UNIMPLEMENTED(); | 10981 UNIMPLEMENTED(); |
| 10951 USE(instr); | 10982 USE(instr); |
| 10952 return 0; | 10983 return 0; |
| 10953 } | 10984 } |
| 10954 | 10985 |
| 10955 EVALUATE(STRVG) { | |
| 10956 UNIMPLEMENTED(); | |
| 10957 USE(instr); | |
| 10958 return 0; | |
| 10959 } | |
| 10960 | |
| 10961 EVALUATE(CGF) { | 10986 EVALUATE(CGF) { |
| 10962 UNIMPLEMENTED(); | 10987 UNIMPLEMENTED(); |
| 10963 USE(instr); | 10988 USE(instr); |
| 10964 return 0; | 10989 return 0; |
| 10965 } | 10990 } |
| 10966 | 10991 |
| 10967 EVALUATE(CLGF) { | 10992 EVALUATE(CLGF) { |
| 10968 UNIMPLEMENTED(); | 10993 UNIMPLEMENTED(); |
| 10969 USE(instr); | 10994 USE(instr); |
| 10970 return 0; | 10995 return 0; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 10992 DCHECK_OPCODE(STRV); | 11017 DCHECK_OPCODE(STRV); |
| 10993 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 11018 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 10994 int32_t r1_val = get_low_register<int32_t>(r1); | 11019 int32_t r1_val = get_low_register<int32_t>(r1); |
| 10995 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 11020 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 10996 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 11021 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 10997 intptr_t mem_addr = b2_val + x2_val + d2; | 11022 intptr_t mem_addr = b2_val + x2_val + d2; |
| 10998 WriteW(mem_addr, ByteReverse(r1_val), instr); | 11023 WriteW(mem_addr, ByteReverse(r1_val), instr); |
| 10999 return length; | 11024 return length; |
| 11000 } | 11025 } |
| 11001 | 11026 |
| 11027 EVALUATE(STRVG) { |
| 11028 DCHECK_OPCODE(STRVG); |
| 11029 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 11030 int64_t r1_val = get_register(r1); |
| 11031 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 11032 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 11033 intptr_t mem_addr = b2_val + x2_val + d2; |
| 11034 WriteDW(mem_addr, ByteReverse(r1_val)); |
| 11035 return length; |
| 11036 } |
| 11037 |
| 11002 EVALUATE(STRVH) { | 11038 EVALUATE(STRVH) { |
| 11003 DCHECK_OPCODE(STRVH); | 11039 DCHECK_OPCODE(STRVH); |
| 11004 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); | 11040 DECODE_RXY_A_INSTRUCTION(r1, x2, b2, d2); |
| 11005 int32_t r1_val = get_low_register<int32_t>(r1); | 11041 int32_t r1_val = get_low_register<int32_t>(r1); |
| 11006 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); | 11042 int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); |
| 11007 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); | 11043 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); |
| 11008 intptr_t mem_addr = b2_val + x2_val + d2; | 11044 intptr_t mem_addr = b2_val + x2_val + d2; |
| 11009 int16_t result = static_cast<int16_t>(r1_val >> 16); | 11045 int16_t result = static_cast<int16_t>(r1_val >> 16); |
| 11010 WriteH(mem_addr, ByteReverse(result), instr); | 11046 WriteH(mem_addr, ByteReverse(result), instr); |
| 11011 return length; | 11047 return length; |
| (...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12565 return 0; | 12601 return 0; |
| 12566 } | 12602 } |
| 12567 | 12603 |
| 12568 #undef EVALUATE | 12604 #undef EVALUATE |
| 12569 | 12605 |
| 12570 } // namespace internal | 12606 } // namespace internal |
| 12571 } // namespace v8 | 12607 } // namespace v8 |
| 12572 | 12608 |
| 12573 #endif // USE_SIMULATOR | 12609 #endif // USE_SIMULATOR |
| 12574 #endif // V8_TARGET_ARCH_S390 | 12610 #endif // V8_TARGET_ARCH_S390 |
| OLD | NEW |